0
我在Android的meteor/cordova應用程序中創建了一個非常標準的移動slideOut菜單。我安裝了crosswalk package,並且在用戶界面性能方面看到了驚人的提升,除了我用於菜單和其他滑動面板的touchmove事件。下面是觸摸事件的代碼。Android上的crossWalk cordova touchmove性能問題
/* Touch Events - Nav */
var el = document.getElementById('appnavigation');
var touchPos;
var start = function(event) {
var touch = event.touches[0] ||
event.changedTouches[0];
touchPos = touch.clientX;
el.style.transition = 'transform 0.08s';
};
var end = function(event) {
var touch = event.touches[0] ||
event.changedTouches[0];
var pos = el.getBoundingClientRect().left;
if (Math.abs(pos) > 160) {
App.Util.toggleVisible('nav');
}
el.style.transition = '';
el.style.transform = '';
};
var move = function(event) {
var touch = event.touches[0] ||
event.changedTouches[0];
var x = Math.abs(touch.clientX - touchPos);
if (touch.clientX > 0 && x > 0) {
el.style.transform = 'translate3d(-' + x + 'px, 0, 0)';
}
};
// attach event listeners
el.addEventListener('touchstart', start, false);
el.addEventListener('touchend', end, false);
el.addEventListener('touchcancel', end, false);
el.addEventListener('touchmove', move, false);
這個工程,但變得零星laggy,任何幫助將是偉大的。