Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix call scrollingComplete twice when snap #68

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions src/Scroller.js
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,7 @@ var Scroller;
* @param animate {Boolean?false} Whether the scrolling should happen using an animation
* @param zoom {Number?null} Zoom level to go to
*/
scrollTo: function(left, top, animate, zoom) {
scrollTo: function(left, top, animate, zoom, _callback) {

var self = this;

Expand Down Expand Up @@ -592,6 +592,9 @@ var Scroller;
// that rendered position is really in-sync with internal data
if (left === self.__scrollLeft && top === self.__scrollTop) {
animate = false;
if (_callback) {
_callback();
}
}

// Publish new values
Expand Down Expand Up @@ -1213,12 +1216,8 @@ var Scroller;

var completed = function(renderedFramesPerSecond, animationId, wasFinished) {
self.__isDecelerating = false;
if (self.__didDecelerationComplete) {
self.options.scrollingComplete();
}

// Animate to grid when snapping is active, otherwise just fix out-of-boundary positions
self.scrollTo(self.__scrollLeft, self.__scrollTop, self.options.snapping);
self.scrollTo(self.__scrollLeft, self.__scrollTop, self.options.snapping, null, self.__didDecelerationComplete && self.options.scrollingComplete);
};

// Start animation and switch on flag
Expand Down