azoff/Overscroll — Issue #34: Handle scroll event to position thumbs
Author: coeamyd
Created: 2011-12-06 14:43:00+00:00
State: open

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);