ftlabs/ftscroller

segmentwillchange event fired incorrectly ?

Opened this issue · 2 comments

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.

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.

Would greatly appreciate a fix to this issue as well.