Jump to content
Search Community

Have Item Within A Timeline Keep Its End Animation State Even When Other Items With The Same CSS Class Animate In

emilychews test
Moderator Tag

Recommended Posts

Hi,

 

I have a scrollTrigger which animates an image overlay in an out. During the animation when the image cover is at 100% width the image appears behind the cover so when the cover then animates out in the second part of the animation the image is revealed.

 

The problem I have is that when next instance of an image appears the scrollTrigger causes all of the images to disappear again because opacity 0 is set.

 

I'm trying to work out a way of having it so once each image instance appears it will then stay at opacity: 1 

 

Is there anyway of adding a CSS class via scrollTrigger so in my CSS I can have something like  .image.done {opacity: 1} or is there a better way of doing this?

 

The other part of the animation isn't affected because it is covered by theforEach() method that is tied to the scrollTrigger.

 

**Note: in the Codepen the 'image' is the blue inner box 

 

 

 

See the Pen LYRwQdV by emilychews (@emilychews) on CodePen

Link to comment
Share on other sites

Actually Zach that isn't working. The blue square now shows at the beginning of animation. It's only supposed to show after the cover has animated away, so it's basically revealed as the overlay animates out. I encountered this problem when I tried setting the initial value in my CSS.

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