Skip to content
New issue

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

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

autoscroll sends to many events #724

Closed
nros opened this issue Apr 2, 2012 · 2 comments
Closed

autoscroll sends to many events #724

nros opened this issue Apr 2, 2012 · 2 comments

Comments

@nros
Copy link

nros commented Apr 2, 2012

Autoscroll binds to event "onSeek". The event handler "scoll()" calls "api.next()" after a couple of seconds which in turn sends a new seek event "onSeek". Thus an intended Loop is created.

In case the user scrolls manualy the already times call to "api.next()" still is in place. Thus it may happen, that the user selects to scroll to the next element and immediately afterwards an additional scroll is performed.

Additionally every manual scroll of the scrollable creates a new event loop.

To fix this, an extended detection of times onSeek event handlers is needed. The following patch resolves the issue for us. Please revise it. It would be gread if you could add similar checks to your code.

--- scrollable.autoscroll.js.orig   2012-04-02 12:38:31.000000000 +0200
+++ scrollable.autoscroll.js    2012-04-02 12:34:07.000000000 +0200
@@ -36,7 +36,7 @@
            var api = $(this).data("scrollable"),
                root = api.getRoot(),
                // interval stuff
-               timer, stopped = false;
+               timer, stopped = false, skipNextTimer = false;

        /**
       *
@@ -44,9 +44,19 @@
       *   Fixes this bug: http://flowplayer.org/tools/forum/25/72029
       */
       function scroll(){        
+        if (typeof(timer) == "undefined" || !timer) {
         timer = setTimeout(function(){
+               timer = false;
+               if (skipNextTimer) {
+                   skipNextTimer = false;
+                   scroll();
+               }  else {
           api.next();
+               }
         }, opts.interval);
+        } else {
+            skipNextTimer = true;
+        }
       }

            if (api) { ret = api; }
@alexeych
Copy link

alexeych commented Apr 6, 2012

Yep, Scrollable events are buggy (e.g. #718) and autoscroll is too buggy. Manual navigation during autoscroll makes Scrollable scrolling a bit crazy :)

@nros
Copy link
Author

nros commented Apr 17, 2012

I found this fix: #591 - it is a far better fix
It is already in the mater branch but not yet released.
I have fought with the latest release version.

@nros nros closed this as completed Apr 17, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants