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

ScrollBy/ScrollTo is cancelled during animation #41

Open
OnkelTem opened this issue Sep 20, 2013 · 2 comments
Open

ScrollBy/ScrollTo is cancelled during animation #41

OnkelTem opened this issue Sep 20, 2013 · 2 comments

Comments

@OnkelTem
Copy link

When I call scroller.ScrollBy(..) during manual scrolling animation, it just doesn't work. So I have to wait until animation finishes and call ScrollBy one more time.

Is there a way to stop animation?

@nkabardin
Copy link

I've faced the same issue. But looks like no one cares :(
@aneganov , have you found a solution for that?

@Henne2806
Copy link

Henne2806 commented Jan 30, 2018

For me there are two solutions

  1. Scrolling without animation:
    Call scroller.stop() before you execute scroller.scrollBy()

  2. Scrolling with animation
    The problem ist here, the new animation starts before the old animation was completed.
    In this case the property __isAnimating is set with the id of the new animation. And when the old animation is completed, then the new one will stopped because of this function call in the __publish method:

var wasAnimating = self.__isAnimating
if (wasAnimating) {
	core.effect.Animate.stop(wasAnimating);
	self.__isAnimating = false;
}

So you have to make sure that the new animation starts in a new request animation frame. So i add these lines in the __publish method:

window.requestAnimationFrame(function() {
	// When continuing based on previous animation we choose an ease-out animation instead of ease-in-out
	self.__isAnimating = core.effect.Animate.start(step, verify, completed, self.options.animationDuration, wasAnimating ? easeOutCubic : easeInOutCubic);
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants