ftlabs / ftscroller

FTScroller is a cross-browser Javascript/CSS library to allow touch, mouse or scrollwheel scrolling within specified elements, with pagination, snapping and bouncing support.
MIT License
1.19k stars 121 forks source link

segmentwillchange event fired incorrectly ? #5

Open ghost opened 11 years ago

ghost commented 11 years ago

I am looking at the "Horizontal paged strict version".

If I attach segmentwillchange event as follows:

segmentwillchange = function(changeObject) { console.log(changeObject); }; scroller.addEventListener("segmentwillchange", segmentwillchange);

If I scroll while maintaining mousedown, the event is fired correctly when the segment threshold is crossed.

However, if I scroll "quickly" (ie: mousedown, quick movement left or right, mouseup), then the event fires only when the scroller has finished its animation, not when the threshold is crossed.

rowanbeentje commented 11 years ago

You're right - when an animation is scheduled via feeding the browser a lengthy CSS3 animation and a bezier curve, we're currently not firing the end until cleanup happens at the end.

There's no perfect solution to this, but what we can do is work out if segments will be crossed by a new animation, and schedule setTimeouts to fire at the appropriate points; it may not be perfect, but it'll be relatively accurate - especially in the case of slow animations, where the missing events are probably most obvious at the moment.

membla commented 11 years ago

Would greatly appreciate a fix to this issue as well.