Share Posted June 2, 2013 How would I use greensock js to animate an effect like the one described herein: http://stackoverflow.com/questions/1736922/how-to-show-animated-image-from-png-image-using-javascript-like-gmail My best guess is to tween the value between 0 to 1 of a vanilla javascript object, and onUpdate to do the math to change the css background position to the closest "step". This way I could use any of the easing functions too. But I am wondering if there is a better way? Link to comment Share on other sites More sharing options...
Share Posted June 2, 2013 Sure, you can configure SteppedEase easing ( http://api.greensock.com/js/com/greensock/easing/SteppedEase.html ) . Here is a pen : See the Pen FfeAa by burnandbass (@burnandbass) on CodePen Link to comment Share on other sites More sharing options...
Author Share Posted June 2, 2013 Thanks Bassta This is what I was looking for, but seems to be missing a feature -- it is only linear. How would I use one of the other eases? Link to comment Share on other sites More sharing options...
Share Posted June 2, 2013 Hi; I thought this was the effect you tried to achieve. If you want to "tween" the sequence ( the first frames show faster, the middle stays more etc.) you need a function that calculates the background position and runs on onUpdate() method. I'll try to create you a new pen with this technique later today Link to comment Share on other sites More sharing options...
Author Share Posted June 2, 2013 Bassta -- not to worry, that is the solution I've already implemented. I was hoping there was something like the SteppedEase where you could pass another ease in as a parameter. Link to comment Share on other sites More sharing options...
Share Posted June 2, 2013 Hi; Anyway, here is the new pen: See the Pen qAhpj by burnandbass (@burnandbass) on CodePen I hope it is working for you 1 Link to comment Share on other sites More sharing options...
Share Posted June 3, 2013 That's a good idea bassta, but I'll offer one more option: See the Pen igHft by jamiejefferson (@jamiejefferson) on CodePen One of the really powerful features of GSAP is that you can actually tween the progress (or time) of a linear tween to apply any easing you like to it: var smiley = TweenMax.to("#smile", 1, { backgroundPosition:"0px -574px", ease:SteppedEase.config(41), paused:true }); TweenMax.to(smiley, 3, { progress:1, repeat:-1, ease:Power4.easeInOut }); 7 Link to comment Share on other sites More sharing options...
Share Posted June 3, 2013 var smiley = TweenMax.to("#smile", 1, { backgroundPosition:"0px -574px", ease:SteppedEase.config(41), paused:true }); TweenMax.to(smiley, 3, { progress:1, repeat:-1, ease:Power4.easeInOut }); Very useful, Jamie! Really clean approach! Link to comment Share on other sites More sharing options...
Share Posted June 10, 2015 I know this post is rather old... but anyway the smiley link used in the pens are dead... any chance that you could update the pens? Link to comment Share on other sites More sharing options...
Share Posted December 9, 2015 I know this post is rather old... but anyway the smiley link used in the pens are dead... any chance that you could update the pens? You can use the image: http://ssl.gstatic.com/ui/v1/icons/mail/im/emotisprites/wink2.png Instead, just change it in the background. Link to comment Share on other sites More sharing options...
Share Posted December 9, 2015 Here is a working example of animating a background-image spritesheet using GSAP. See the Pen zrGGmQ by jonathan (@jonathan) on CodePen 1 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