300ms delay removal: using fastclick.js vs using ontouchstart

前端 未结 6 1536
温柔的废话
温柔的废话 2020-12-24 03:06

I\'m using regular jQuery and I have an event handler that looks like this:

$(\'#someID\').on({

   click: SomeFunction

}, \'.SomeClass\');
<
6条回答
  •  太阳男子
    2020-12-24 03:51

    Andrew gives the correct answer.

    In general,

    "touchstart" will be triggered when we perform "click","swipe","scroll" etc. However, as you know, what we want to capture is "click".

    What FastClick.js does is to define a rule for "click". For example, we could set the condition below as a "click":

    During time between "touchstart" and "touchend" is 200ms, in "touchmove", we find no distance has been moved.

    The same, we could set the condition below as a "scroll":

    During "touchstart" and "touchend", in "touchmove", we find distance has been moved on y axis but no x axis moving happens.

提交回复
热议问题