簡體   English   中英

JS區分iPhone上的單擊和滾動

[英]JS distinguish click and scroll on iPhone

我正在嘗試關閉Sidemenu onclick 但是, touchstart還將滾動檢測為點擊, touchend 如何只檢測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%"; 
      }
    });

檢測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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM