0
目前我正在測試這個Zepto Mobile Javascript框架。Zepto Mobile Framework - 瀏覽器中的事件
我下載了這些例子,但奇怪的是,我注意到,在Chrome桌面瀏覽器上,點擊觸發子菜單的項目(通過webkit幻燈片效果)不起作用。
我上傳了我的託管服務器上的相同文件,並在我的iPhone上測試了相同的頁面,它工作得很好。
我檢查了代碼,發現Zepto正在綁定touchstart事件,我認爲它不適用於桌面瀏覽器。
$(document).ready(function(){
$(document.body).bind('touchstart', function(e){
var now = Date.now(), delta = now - (touch.last || now);
touch.target = parentIfText(e.touches[0].target);
touchTimeout && clearTimeout(touchTimeout);
touch.x1 = e.touches[0].pageX;
touch.y1 = e.touches[0].pageY;
if (delta > 0 && delta <= 250) touch.isDoubleTap = true;
touch.last = now;
}).bind('touchmove', function(e){
touch.x2 = e.touches[0].pageX;
touch.y2 = e.touches[0].pageY;
}).bind('touchend', function(e){
if (touch.isDoubleTap) {
$(touch.target).trigger('doubleTap');
touch = {};
} else if (touch.x2 > 0 || touch.y2 > 0) {
(Math.abs(touch.x1 - touch.x2) > 30 || Math.abs(touch.y1 - touch.y2) > 30) &&
$(touch.target).trigger('swipe') &&
$(touch.target).trigger('swipe' + (swipeDirection(touch.x1, touch.x2, touch.y1, touch.y2)));
touch.x1 = touch.x2 = touch.y1 = touch.y2 = touch.last = 0;
} else if ('last' in touch) {
touchTimeout = setTimeout(function(){
touchTimeout = null;
$(touch.target).trigger('tap')
touch = {};
}, 250);
}
});
});
有沒有人在Chrome/Safari上測試Zepto(iPhone示例),他可以設法訪問子菜單?
這是例如URL - https://github.com/madrobby/zepto/blob/master/examples/iphone/index.html
的Zepto演示包URL - https://github.com/madrobby/zepto
感謝