Skip to content

How to Pause/Suspend animation of a Spring (and or Transition) #427

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

Closed
lfpil opened this issue Jan 9, 2019 · 4 comments
Closed

How to Pause/Suspend animation of a Spring (and or Transition) #427

lfpil opened this issue Jan 9, 2019 · 4 comments
Labels
kind: request New feature or request that should be actioned

Comments

@lfpil
Copy link

lfpil commented Jan 9, 2019

Is there a simple way to pause the animation of a Spring?

I've tried to put an infinite friction, but bringing friction back to default would not resume the animation.

Super thanks

@drcmda
Copy link
Member

drcmda commented Jan 9, 2019

Do you have the option to use hooks? This would make it easier. A Spring is a declaration of intent, to pause would essentially conflict with the props-declaration. You can do it, but only through reaching into internals <Spring ref={r => r && r.controller.cancel()} ... />

@lfpil
Copy link
Author

lfpil commented Jan 9, 2019

Thank you for the quick reply.

I'd like to pause an ongoing animation, and be able to resume.

With your indication I tried to used the controller, as in this pen
https://codepen.io/anon/pen/OrwYaL

I couldn't find a cancel method, but stop and start.
Clicking stop would stop the animation at the end.
Clicking start would stop immediatly.

Reclicking start (after first start, or stop) would not resume the animation.

@lfpil
Copy link
Author

lfpil commented Jan 17, 2019

I gave it a try with hooks, but am only partially happy with it.

https://codepen.io/anon/pen/vvVbNZ?editors=0011

Is that what you had in mind when saying hook would make it easier?

Also, the drawback with this approach is that duration seems to be reset.

@aleclarson aleclarson added kind: request New feature or request that should be actioned and removed question labels Apr 15, 2019
@aleclarson
Copy link
Contributor

The pause and cancel props are available in v9. #985

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: request New feature or request that should be actioned
Projects
None yet
Development

No branches or pull requests

3 participants