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

Use requestAnimationFrame for applying the transition #1

Open
roblevintennis opened this issue Aug 12, 2015 · 2 comments
Open

Use requestAnimationFrame for applying the transition #1

roblevintennis opened this issue Aug 12, 2015 · 2 comments

Comments

@roblevintennis
Copy link

I was looking at this issue in our codebase and noticed you had it too in these places:
https://github.com/JSteunou/marionette.csstransition-region/blob/master/marionette.csstransition-region.js#L59
https://github.com/JSteunou/marionette.csstransition-region/blob/master/marionette.csstransition-region.js#L68

I iterated first using _.defer (you can't use since you're not trying to include underscore dependency of course), but, which is ultimately setTimeout with zero ms. As explained to me, it essentially waits for whatever's on the call stack at that moment to complete. Anyway, it worked. Then I thought to try request animation frame which is the best practice these days. That also worked for me in chrome and firefox.

Fwiw, in our coffeescript based codebase, we shimmed it with:

window.requestAnimationFrame = do ->
  window.requestAnimationFrame ||
  window.webkitRequestAnimationFrame ||
  window.mozRequestAnimationFrame ||
  window.oRequestAnimationFrame ||
  window.msRequestAnimationFrame

which is essentially tranposing of Paul Irish's http://www.paulirish.com/2011/requestanimationframe-for-smart-animating/

Hope this helps man :)

@JSteunou
Copy link
Owner

Yep, figure out I should have used raf months ago but that project was just a PoC, never updated since, nor with last marionette neither with all fixes I could think about. But thank you for pointed this out, I will let this open, it could help some people still reading this PoC.

@roblevintennis
Copy link
Author

Sounds good!

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