Jump to content
Search Community

Scroll Trigger Reverse Problem

MaryamZafar test
Moderator Tag

Recommended Posts

Hello!

 

First of all can I just say this framework is AWESOME. 

 

I have a problem - this website, when I scroll down, everything is fine, but when I scroll back up, all my text elemets beautifully reverse their animation, except for the first case study block, which does not fade out but just suddenly disappears if I reverse before reaching the end. How do I fix this problem? The JS code is exactly the same for all of them.

 

here is a screencast: https://drive.google.com/file/d/1uugbp9_ta6RLQjBYexZI-bop8qa-b1mq/view?usp=sharing

 

This is my code:

gsap.from("#case-study-1", {
  scrollTrigger : {
    trigger: "#case-study-1",
    start: "20px 80%",
    toggleActions: "play none reverse reset",
    markers: true,
  },
  y: 200,
  opacity: 0,
  duration: 1
});

 

Link to comment
Share on other sites

Hi! Thank you for your reply - If I change the parameter to none, the reverse doesnt work at all - the image fades in on scroll down, but stays there when I scroll back up...The code on the website has also been updated if you want to take a look please.

 

here is an updated screencast:

 

https://drive.google.com/file/d/1hjZWQ-1BZrNanyqmAJgYhyMlBlq2i4dQ/view?usp=sharing

 

 

Link to comment
Share on other sites

Thanks for the demo. You didn't change the toggleActions to what I suggested, but my suggestion was off anyway. Try 

toggleActions: "play none none reverse"

Is this the effect that you're looking for?

 

Side note: you could make your code more DRY (Don't Repeat Yourself) by using a loop to create these animations and ScrollTriggers since they are the same besides the targets. I talk more about how to do that in my article on animating efficiently which I highly recommend.

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...