[英]JS distinguish click and scroll on iPhone
I'm trying to close a Sidemenu onclick
. 我正在尝试关闭Sidemenu
onclick
。 however, touchstart
also detects scrolling as a click, so is touchend
. 但是,
touchstart
还将滚动检测为点击, touchend
。 how to just detect a click (not a scroll) on iPhone? 如何只检测iPhone上的点击(不是滚动)?
$('#html').on("click touchstart",function(e) {
var optionsmenue = $(".adminmenu_label");
if(!optionsmenue.is(e.target) && optionsmenue.has(e.target).length === 0) {
document.getElementById("Optionsmenu").style.width = "0%";
document.getElementById("Optionsmenu").style.transition = "0.2s ease-out";
document.getElementById("adblue").style.display = "block";
document.getElementById("whatever").style.display = "block";
document.getElementById("not_related").style.display = "block";
document.getElementById("still_not_related").style.display = "block";
document.getElementById("still_still_not_related").style.width = "100%";
}
});
Detecting for iOS and adding cursor:pointer
works for me , IOS seems to have a problem with event delegation. 检测iOS并添加
cursor:pointer
对我有用,IOS似乎在事件委托方面存在问题。
var iOS = ["iPad","iPhone","iPod"].indexOf(navigator.userAgent) > -1;
if(iOS) {
$('body').css({ cursor : 'pointer' });
}
$('#html').on("click",function(e) {
// No need for touch start click will do the trick;
});
应该删除“ touchstart”
$('#html').on("click touchstart",function(e) {
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.