Jump to content
Search Community

Change image exit effect to fade out

cerealbeast test
Moderator Tag

Go to solution Solved by Cassie,

Recommended Posts

  • Solution

Heya! Sure thing - Anything is possible 🌈 That's the magic of GSAP

I can't fork this as it's a private pen - but you'll ned to tweak the tweens in the showImage and hideImage functions...

It looks a little complex to me, not sure what revealInner is in this case... but revealImg is what you want to target.

 

  showImage() {
    //...

    this.tl = gsap
      .timeline({
        onStart: () => {
          this.DOM.reveal.style.opacity = 1;
          gsap.set(this.DOM.el, {
            zIndex: 1000
          });
          // make sure it's visible again before the showimage animation!
           gsap.set(this.DOM.revealImg, {
            opacity: 1
          });
        }
      })
      //...
  }
  hideImage() {
    //...
    this.tl = gsap
      .timeline({
        onStart: () => {
          gsap.set(this.DOM.el, {
            zIndex: 999
          });
        },
        onComplete: () => {
          gsap.set(this.DOM.el, {
            zIndex: ""
          });
          gsap.set(this.DOM.reveal, {
            opacity: 0
          });
        }
      })
      .add("begin")
      // Add whatever animation you want for the 'hide' bit here... 
      .add(
        gsap.to(this.DOM.revealImg, {
          duration: 1,
          ease: "sine.out",
          opacity: 0
        }),
        "begin"
      );
  }
}
  • 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...