cubiq / iscroll

Smooth scrolling for the web
http://iscrolljs.com
MIT License
12.87k stars 3.8k forks source link

Click event fired even after touchmove #505

Open tjwoon opened 11 years ago

tjwoon commented 11 years ago

Steps to reproduce:

  1. Create an iScroll with .hasHorizontalScroll = false.
  2. Drag your finger horizontally a long distance. You may expect the gesture to be recognised as a drag / invalidated as a click.
  3. Release your finger - the click event is fired.

Related: https://github.com/cubiq/iscroll/issues/499

This quick hack seems to fix the issue for me in the Android browser (Android 4.1.2, iScroll v5.0.5 - iscroll-zoom.js) Desktop Chrome is still wonky but it doesn't matter for my immediate requirements so I have not investigated it much yet.

433a434,438
>         // We need to move at least 10 pixels for the scrolling to initiate
>         if ( timestamp - this.endTime > 300 && (Math.abs(point.pageX - this.pointX) < 10 && Math.abs(point.pageY - this.pointY) < 10) ) {
>             return;
>         }
>
442,446d446
<       // We need to move at least 10 pixels for the scrolling to initiate
<       if ( timestamp - this.endTime > 300 && (absDistX < 10 && absDistY < 10) ) {
<           return;
<       }
<
miladrasooli commented 11 years ago

This easiest solution is to sum the distance with the position. (sorry if I can't say my point, My English is poor). Something like the probe demo in iscroll v5. But the Y position should not decrease.

distance+=this.y; //////////////////////////////////// if (distance>10) e.preventDefault();

Thanks.