Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Preventing next click after scrolling #12

Open
iscy opened this Issue Jun 2, 2010 · 3 comments

Comments

Projects
None yet
3 participants

iscy commented Jun 2, 2010

On the iPhone:

  1. Scroll on a page
  2. Hit an element that has onClick() function
    => Nothing happens
  3. Hit it again
    => Works

The function: _preventNextClick() is the root cause of this issue. I'm not sure why this function was introduced in the first place... but removing its call from onTouchMove fixes my issue. I think the handler should be removed from onTouchEnd().

iscy commented Jun 2, 2010

Here is a patch that fixes the issue by removing the prevent handler on onTouchEnd().

Index: web/touchscroll.js
===================================================================
--- web/touchscroll.js  (revision 5168)
+++ web/touchscroll.js  (working copy)
@@ -639,6 +639,8 @@
 
                                this.startFlick(flickVector, flickDuration);
                        }
+
+                       scroller.removeEventListener("click", preventHandler, true);
                }
 
                if(!(this.isAnimating())){
@@ -667,13 +669,15 @@
        _preventNextClick: function _preventNextClick(){
                var scroller = this.scrollers.container;
                scroller.style.webkitTapHighlightColor = "transparent";
-               scroller.addEventListener("click", function prevent(event){
-                       event.stopPropagation();
-                       this.removeEventListener("click", prevent, true);
-                       this.style.webkitTapHighlightColor = "";
-               }, true);
+               scroller.addEventListener("click", preventHandler, true);
        },
 
+       _preventHandler: function _preventHandler(event) {
+               event.stopPropagation();
+               scroller.removeEventListener("click", preventHandler, true);
+               scroller.style.webkitTapHighlightColor = "";
+       },
+
        isAnimating: function isAnimating(){
                var timeouts = this._animationTimeouts;
                var hasTimeouts = timeouts.e.length > 0 || timeouts.f.length > 0;
Owner

davidaurelio commented Jul 15, 2010

Thanks for the patch … this will be fixed with the rewrite, I just don’t have much time left to finish it at the moment.

This is still happening (at least on Android phones), and I don't see that _preventNextClick function anywhere in the code, so I don't know how can I patch it. Any workaround for this? The project doesn't seem pretty active right now, but i'm hoping someone can answer me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment