PDA

View Full Version : how to get the scroll direction in "scroll" event



aj3423
14 Dec 2010, 6:19 PM
el.on('scroll', function(e, t, o) {
// I didn't find 'horizontalscroll' or 'verticalscroll' event
// both horizontal scroll and vertical scroll causes this event,
// how can i know which one caused this?
// Thanks.
});

Animal
14 Dec 2010, 10:26 PM
You have to cache the scrollTop and scrollLeft values and calculate the deltas.

aj3423
14 Dec 2010, 11:11 PM
Thanks Animal, this is really tricky, maybe I should write a plugin for this.

Animal
15 Dec 2010, 12:30 AM
Yes, that should be easy. Set properties in the Component in the init() method, and then use them to calculate the deltas on every scroll event.