我正在使用这段很棒的代码来模拟Android http://pervasivecode.blogspot.co.nz/2011/11/android-phonegap-active-css-pseudo.html上的触摸事件。效果很好,但太敏感了。例如,如果您有一个列表,并且想要在触摸列表上的任何内容时向下滚动,则该列表将突出显示一个链接。
$(document).ready(function(){
if (navigator.userAgent.toLowerCase().indexOf("android") > -1) {
$('a')
.bind("touchstart", function () {
$(this).addClass("fake-active");
})
.bind("touchend", function() {
$(this).removeClass("fake-active");
});
}
});是否有可能延迟类的更改,或者是否有其他触发器可以使用?
发布于 2013-05-07 10:17:55
为了避免在滚动时激活链接,您可以使用touchend来触发类更改,并检查是否存在滚动。就像这样..。
if (navigator.userAgent.toLowerCase().indexOf("android") > -1){
var scroll = 0;
$('a').on("touchstart",function(){
$('a').removeClass("fake-active");
}).on("touchend",function(){
if(scroll == 0){
$(this).addClass("fake-active");
}
scroll = 0; //Ideally should be set when scrolling is finished
});
$('ELEMENT-THAT-IS-SCROLLING').scroll(function(){
scroll = 1;
});
}https://stackoverflow.com/questions/9375130
复制相似问题