Jump to content
Search Community

Animating ::before Element on slides

Chybosky test
Moderator Tag

Go to solution Solved by PointC,

Recommended Posts

Hello Community,
Please I need some assistances with Animating the ::before element on each slides. I tried but the text keeps coming before the ::before (Rectangle background) element.

 

I would like to make the rectangle comes first then the text over it second. The Text can start coming over it halfway when the rectangle enters the banner and reverse the flow on exit.
 


 

See the Pen oNpKRvz?editors=1010 by Chybosky (@Chybosky) on CodePen

Link to comment
Share on other sites

Thank you so much @PointC

This is the changes I made:


See the Pen oNpKRvz by Chybosky (@Chybosky) on CodePen

 

I have made the changes and I can separate the animation for both the text and the :after element but I have some issues that I encountered. One of the issues is  The ::after(background) element does not come first after the first slide passes. The second issue is with the SmoothScroller Script, I had some issues testing it on a live website. Please how can I resolve it.

Thank you

 

Link to comment
Share on other sites

48 minutes ago, Chybosky said:

The ::after(background) element does not come first after the first slide passes.

Looks like you're making one big timeline, but you're hard coding the text spans at 0.55. You probably want something more like this. 

 tl.to(slide.querySelector(".slider__header"), { "--scaleX": 1 });
 tl.from(slide.querySelector(".slider__header span"), { x: -50, autoAlpha: 0}, "<+=0.55");

My demo created individual timelines. Not that you can't make one big timeline, but my personal preference would be to create child timelines in the loop and add them to a parent. Makes it really easy to control and adjust the timeScale() of the parent.

 

48 minutes ago, Chybosky said:

The second issue is with the SmoothScroller Script

I'm not seeing that being used in your demo, but you're not allowing vertical scrolling here so you'd want to take a look at some of the ScrollTrigger pinning demos.

 

One other minor note:

There are missing targets and you're loading two versions of GSAP.

 

Hopefully that helps. Happy tweening.

:) 

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