Click event called twice on touchend in iPad

后端 未结 3 1580
伪装坚强ぢ
伪装坚强ぢ 2020-11-30 00:44

I am using jquery animate for the slide. I have an arrow at the end of the slide and given the click event on that arrow. The working of it is to move one item inside the si

3条回答
  •  天涯浪人
    2020-11-30 01:33

    Extending H Dog answer. Here is the code that worked for me.

     if (isTouchSupported) {
        $('#playanimationbtn').off("mouseup");
        $('#stopanimationbtn').off("mouseup");
        $('#playanimationbtn').off("mousedown");
        $('#stopanimationbtn').off("mousedown");
        $('#playanimationbtn').off("click");
        $('#stopanimationbtn').off("click");
        document.getElementById("playanimationbtn").addEventListener("touchend", PlayAnimation);
        document.getElementById("stopanimationbtn").addEventListener("touchend", StopAnimation);
    } else {
        $('#playanimationbtn').off("touchstart");
        $('#playanimationbtn').off("touchend");
        $('#playanimationbtn').off("touchmove");
        $('#playanimationbtn').off("touchend");
        $('#playanimationbtn').off("touchleave");
        $('#stopanimationbtn').off("touchstart");
        $('#stopanimationbtn').off("touchend");
        $('#stopanimationbtn').off("touchmove");
        $('#stopanimationbtn').off("touchend");
        $('#stopanimationbtn').off("touchleave");
        document.getElementById("playanimationbtn").addEventListener("click", PlayAnimation);
        document.getElementById("stopanimationbtn").addEventListener("click", StopAnimation);
    }
    

提交回复
热议问题