Jump to content
Search Community

crossfade image zoom effect

Nwekar test
Moderator Tag

Go to solution Solved by Rodrigo,

Recommended Posts

  • Solution

Hi @Nwekar,

 

Does this solves your issue?:

useEffect(() => {
  let tl = gsap.timeline({ repeat: -1 }),
      fadeDuration = 3.5,
      stayDuration = 3;

  let images = [...parentHero.current.children].slice(3);
  gsap.set(images[0], { autoAlpha: 1, scale: 1.1 });
  tl.to(images.slice(1), { delay: stayDuration, autoAlpha: 1, scale: 1.1, duration: fadeDuration, stagger: stayDuration + fadeDuration })
    .to(images.slice(0, images.length - 1), { autoAlpha: 0, duration: 0.01, stagger: stayDuration + fadeDuration }, stayDuration + fadeDuration)
    .set(images[0], { autoAlpha: 1, scale: 1 })
    .to(images[images.length - 1], { autoAlpha: 0, duration: fadeDuration }, "+=" + stayDuration)
    .to(images[0], { scale: 1.1, duration: fadeDuration }, "<");
  return () => {
    tl.revert();
  }
}, []);

Basically I would start the whole thing with the first image with the scale applied to it, then when you reset the opacity you can also reset the scale, otherwise you get a jump on the first image scale when the timeline restarts. Finally you needed to add an instance for the scaling of the first image that starts at the same time as the previous instance in the timeline.

 

You can learn more about it here:

https://greensock.com/docs/v3/GSAP/Timeline

https://greensock.com/position-parameter

 

Happy Tweening!!!

  • Like 1
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...