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

Listen for transition end #12

Open
jimblue opened this issue Feb 19, 2018 · 3 comments
Open

Listen for transition end #12

jimblue opened this issue Feb 19, 2018 · 3 comments

Comments

@jimblue
Copy link

jimblue commented Feb 19, 2018

You're using requestAnimationFrame two times but without changing dom propriety from javascript.
I don't see how this can improve performance as you add class to animate dom element.

I can be wrong of course, if it's the case please light me candle 👍

requestAnimationFrame(() => {

requestAnimationFrame(() => {

@electerious
Copy link
Owner

The first requestAnimationFrame is there to ensure that the class change triggers the animation. You have to wait a frame after adding the element to the DOM. Otherwise it wouldn't do the transition to the basicLightbox--visible class.

I'm not sure if there's a reason for the second requestAnimationFrame. I would say that it's useless. Might be worth a try. We could also use a keyframe animation and avoid requestAnimationFrame completely.

@jimblue
Copy link
Author

jimblue commented Feb 23, 2018

Ok I got it, thanks you 😄 !

Also I think you could provide a better callback here:

Why don't you listen for animation end?

@electerious
Copy link
Owner

Removed the second requestAnimationFrame: https://github.com/electerious/basicLightbox/blob/master/CHANGELOG.md#401---2018-02-23

Listening for animation end would be better. PR welcome :)

@electerious electerious changed the title Why using requestAnimationFrame with class Listen for transition end Feb 24, 2018
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