Skip to content

Handle scroll event to position thumbs #34

Closed
coeamyd opened this Issue Dec 6, 2011 · 0 comments

2 participants

@coeamyd
coeamyd commented Dec 6, 2011

When using the scrollIntoView() method to position scrolled content, the thumbs are not repositioned accordingly. This can be achieved by handling the element's scroll event.

Unified diff of required changes:

@@ -51,8 +51,9 @@
         events: {
             wheel: "mousewheel DOMMouseScroll",
             start: "mousedown",
             drag: "mousemove",
             end: "mouseup mouseleave click",
+            scroll: "scroll",
             ignored: "select dragstart drag"
         },

@@ -123,8 +125,9 @@
                     overflow: 'hidden',
                     cursor: data.cursors.grab
                 }).on(o.events.wheel, data, o.wheel)
                   .on(o.events.start, data, o.start)
                   .on(o.events.end, data, o.stop)
+                  .on(o.events.scroll, data, o.scroll)
                   .on(o.events.ignored, false);

                 if (options.showThumbs) {
@@ -399,9 +402,17 @@

             }

            data.target.css('cursor', data.cursors.grab);

         },
+        
+        scroll: function (event) {
+            var data = event.data, flags = data.flags;
+            
+            if (!flags.dragging) {
+                o.moveThumbs(data, this.scrollLeft, this.scrollTop);
+            }
+        },

         clearInterval: function (target) {
             target = $(target);
@azoff azoff pushed a commit that closed this issue Dec 12, 2011
Jonathan Azoff merged in changes from coeamyd/master. Closes #33 and closes #34 f86cc67
@azoff azoff closed this in f86cc67 Dec 12, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.