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

Is there a way to animate popovers? #141

Open
JonCognioDigital opened this issue Oct 6, 2021 · 2 comments
Open

Is there a way to animate popovers? #141

JonCognioDigital opened this issue Oct 6, 2021 · 2 comments

Comments

@JonCognioDigital
Copy link

I'd like to animate mine using transform: translateY() or something similar so that it quickly rises up into position and fades in.

Is there a suggested way to do this? Is it possible to use other animation libraries on the contents of the content={} prop? or is there a better way to do this?

@alexkatz
Copy link
Owner

alexkatz commented Oct 6, 2021

I recommend using the popover in conjunction with whatever animation library you feel comfortable with.

I've had good results with react-spring. If I have time, I'll post some examples soon.

Animating in is pretty straightforward -- just kick the animation off when the popover appears the same way you would anywhere else in your app. I would refrain from animating the div container that react-tiny-popover creates, and instead focus on animating the content you have within it. You can set overflow on the popover container to visible if you anticipate the animation exceeding the bounds of the popover container.

Animating out is a little trickier. You have to wait for the animation to complete before closing the popover, as closing the popover will immediately remove it from the DOM altogether.

Most animation libraries have some sort of onAnimationEnd or onRest callback within which you can set the popover to closed. This way, your content will fade out, or fly off the screen, or whatever, and then invisibly be removed from the DOM.

Hope this helps.

@JonCognioDigital
Copy link
Author

Thanks, I'll look into react spring. An example would be awesome!

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

2 participants