Jump to content
Search Community

Is there a way to infinitly scale an image

Jonathan test
Moderator Tag

Warning: Please note

This thread was started before GSAP 3 was released. Some information, especially the syntax, may be out of date for GSAP 3. Please see the GSAP 3 migration guide and release notes for more information about how to update the code to GSAP 3's syntax. 

Recommended Posts

Hello,

 

Im trying to find away to infinitely scale an image. The only way i can think of is using a recursive function. I tried to use 'repeat: -1, but it just restarts the tween from the beginning value of the css property.

start();
function start(){
       TweenMax.to($(img),
                   4,
                   { css:{ scale:'+=0.5' },
                   ease: Power0.easeInOut,
                   onComplete: function(){
                            start(); 
                   }
         });
}

I was wondering if there is a better way using TweenMax or TimelineMax to infinitely scale an image? Either using (transform) scale or width and height (css or dom).

 

Basically I want to keep animating the value up, infinitely. By incrementing up, infinitely.

 

Any help will be highly appreciated! Thank You!

Link to comment
Share on other sites

I see nothing wrong with your recursive function approach, and it's what I would have recommended had you not already suggested it.

 

I had a play around and it seems this pattern would also work, although you can decide if it's "better".

TweenMax.to($(img), 4, {
  scale:"+=0.5",
  ease: Power0.easeInOut,
  onComplete:function(tween) {
    tween.invalidate().progress(0);
    // clear starting values, move playhead to the beginning for repeat
  },
  onCompleteParams:["{self}"]
});
  • Like 2
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...