【发布时间】:2015-06-19 03:15:23
【问题描述】:
我使用 Cordova 开发了一个在 Android 5.0 之前运行良好的应用。该应用程序的问题是我可以滑动,但是我无法点击/触摸我的应用程序中的特定元素(实际上,如果我多次点击它就可以工作)。一些水龙头按预期工作,例如按钮。然而,其他元素,如图像等,它不起作用(我在轮播中有图像,点击时会执行一个功能)
谁能帮助解释为什么会发生这种情况,并且只发生在 Android 4.4.4 及更高版本上。
我的代码在下面
nova.touch.bindClick = function(selector, func) {
if (nova.application.isTouchable === false) {
$(selector).click(function(e) {
func.call(this, e);
});
return;
}
var isMoving = false;
var startTime = null;
$(selector).bind(this.eventNames.touchstart, function(e) {
isMoving = false;
startTime = new Date();
$(this).addClass("touching");
});
$(selector).bind(this.eventNames.touchmove, function(e) {
isMoving = true;
});
$(selector).bind(this.eventNames.touchend, function(e) {
var $me = $(this);
$me.removeClass("touching");
var duration = new Date() - startTime;
if (!isMoving && duration < 1000) {
$me.addClass("clicking");
func.call(this, e);
setTimeout(function() {
$me.removeClass("clicking");
}, 500);
}
});
};
如上所述,这适用于旧版本的 Android 和所有版本的 iOS。只有新版本的安卓有这个问题。
【问题讨论】:
-
在设备上运行时 chrome 开发者控制台中是否有任何错误? developer.chrome.com/devtools/docs/remote-debugging
-
@MarkVeenstra 没有错误,代码在 Chrome 和 iOS 中只能在 Android 4.4.4 中正常运行跨度>
标签: android cordova touch-event