Share Posted January 12, 2016 I'm trying to tween an animation controlled with scrolling. Looking for some help, it works fine in FireFox but not Google Chrome. Wondering if someone can help explain whats going on. See the Pen gPRNQX by SaintDominic138 (@SaintDominic138) on CodePen Link to comment Share on other sites More sharing options...
Share Posted January 12, 2016 Hi SaintDominic138 pls check this out : See the Pen eJRqov by MAW (@MAW) on CodePen 2 Link to comment Share on other sites More sharing options...
Share Posted January 12, 2016 It probably has to do with setting the right css property to 0. Here, I'm setting the x property in Javascript and then animating from there back to 0. See the Pen qbjezo by sgorneau (@sgorneau) on CodePen EDIT: And I've done it again ... sorry Diaco ... didn't see your post until I submitted. 2 Link to comment Share on other sites More sharing options...
Share Posted January 12, 2016 As a rule of thumb you should never animate the CSS position offset properties.. top, bottom, right, or left You should use x and y instead so you can trigger hardware acceleration and sub-pixel rendering. So you can tween x instead of left for better performance and to get that GSAP buttery smoothness See this article by GreenSock's Mighty Jack: https://css-tricks.com/myth-busting-css-animations-vs-javascript/ And this other article: http://www.paulirish.com/2012/why-moving-elements-with-translate-is-better-than-posabs-topleft/ 3 Link to comment Share on other sites More sharing options...
Author Share Posted January 12, 2016 awesome!! thanks everybody! Link to comment Share on other sites More sharing options...
Share Posted January 13, 2016 Hello, try : $(window).scroll(function() { var offset = $(this).scrollTop(); if( offset >= 100 ){ var tl = new TimelineLite; tl.to(".red", 1, {left:00} ); } }); Cordialy Frederic Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now