robinrodricks / vue3-touch-events

Simple touch events support for vue.js 3
MIT License
216 stars 27 forks source link

v-touch:tap gets triggered even if mousedown/touchstart happens outside of the element in a weird scenario #14

Open c4b4d4 opened 2 years ago

c4b4d4 commented 2 years ago

There's a weird bug I have noticed, that under a certain circunstance the :tap method gets triggered when it should not.

(There's an option related to this issue called tapTolerance)

How is it happening?

Let's call the following flow as "Flow 1"

  1. Mousedown any part of the screen without doing it over the element of interest.
  2. Without releasing the mousedown, go over the element of interest and release the mousedown over the element.
  3. The :tap event gets triggered

This always happens, until I trigger the tapTolerance condition over the element.

What do I mean with triggering the tapTolerancecondition?

Lets say I left the tapTolerance to it's defaults of 10px, if I do the following:

And let's call the following flow as "Flow 2"

  1. Mouse down over the element of interest
  2. Move the cursor more than 10px
  3. The :tap event does not get triggered

No matter how many times I repeat the Flow 1 steps, I always get the :tap event triggered, when it shouldn't because I didn't start the click/touch over the element of interest.

But as soon as I do the Flow 2 steps once, Flow 1 no longers triggers :tap event. This should be the desired behavior all the time.