您是否試過包括Zepto.js而不是標準的Javascript庫而不是普通的Jquery.js文件?
它的響應速度快很多,因爲它是一個較輕的軟件包,可以照在慢速Android模擬器上。
爲了測試您的單擊事件,並加快響應點擊,包括來自fwebdev
如果這兩個不工作fastclick.js,嘗試海豚瀏覽器:https://play.google.com/store/apps/details?id=mobi.mgeek.TunnyBrowser&hl=en
https://gist.github.com/2168307
//======================================================== FASTCLICK
function FastButton(element, handler) {
this.element = element;
this.handler = handler;
element.addEventListener('touchstart', this, false);
};
FastButton.prototype.handleEvent = function(event) {
switch (event.type) {
case 'touchstart': this.onTouchStart(event); break;
case 'touchmove': this.onTouchMove(event); break;
case 'touchend': this.onClick(event); break;
case 'click': this.onClick(event); break;
}
};
FastButton.prototype.onTouchStart = function(event) {
event.stopPropagation();
this.element.addEventListener('touchend', this, false);
document.body.addEventListener('touchmove', this, false);
this.startX = event.touches[0].clientX;
this.startY = event.touches[0].clientY;
isMoving = false;
};
FastButton.prototype.onTouchMove = function(event) {
if(Math.abs(event.touches[0].clientX - this.startX) > 10 || Math.abs(event.touches[0].clientY - this.startY) > 10) {
this.reset();
}
};
FastButton.prototype.onClick = function(event) {
this.reset();
this.handler(event);
if(event.type == 'touchend') {
preventGhostClick(this.startX, this.startY);
}
};
FastButton.prototype.reset = function() {
this.element.removeEventListener('touchend', this, false);
document.body.removeEventListener('touchmove', this, false);
};
function preventGhostClick(x, y) {
coordinates.push(x, y);
window.setTimeout(gpop, 2500);
};
function gpop() {
coordinates.splice(0, 2);
};
function gonClick(event) {
for(var i = 0; i < coordinates.length; i += 2) {
var x = coordinates[i];
var y = coordinates[i + 1];
if(Math.abs(event.clientX - x) < 25 && Math.abs(event.clientY - y) < 25) {
event.stopPropagation();
event.preventDefault();
}
}
};
document.addEventListener('click', gonClick, true);
var coordinates = [];
function initFastButtons() {
new FastButton(document.getElementById("fastclick"), goSomewhere);
};
function goSomewhere() {
var theTarget = document.elementFromPoint(this.startX, this.startY);
if(theTarget.nodeType == 3) theTarget = theTarget.parentNode;
var theEvent = document.createEvent('MouseEvents');
theEvent.initEvent('click', true, true);
theTarget.dispatchEvent(theEvent);
};
//========================================================
//When using jQuery call init on domReady-Event
$(document).ready(function() {
initFastButtons();
})
燦你向我展示你的avd(Android虛擬設備)的設置?我假設你已經嘗試從頭重新創建它? –
另外我真的建議你嘗試設置一個x86模擬器圖像,手臂仿真非常慢,在我的經驗比手臂圖像更多的錯誤。您還需要安裝HAXM以加速其速度,並啓用GPU加速。最後,我總是給它一些SDCard空間。 http://developer.android.com/tools/devices/emulator.html如果由於某種原因,這些都不適合你,你可能想給http://androvm.org/blog/一個嘗試。 –
@PaulHarris以下是我的AVD設置。請注意,我爲2個avd設置了相同的行爲(一個用於2.2,另一個用於4.1.2): 'hw.lcd.density = 240 hw.screen = touch skin.name = WVGA800 皮膚。路徑=平臺/機器人-8 /皮/ WVGA800 hw.cpu.arch =手臂 abi.type = armeabi hw.keyboard =是 vm.heapSize = 24 image.sysdir.1 =平臺/機器人-8/images /' – Manachi