Jump to content
Search Community

tl.play() does not work inside an IntersectionObserver

Guest
Moderator Tag

Go to solution Solved by nico fonseca,

Recommended Posts

I created an animation and I am trying to make make it run using an observer but it does not work and I don't know why. Can you please tell me what I am doing wrong?

I added the text to simulate the content on my project

See the Pen powjqyg by raul-rogojan (@raul-rogojan) on CodePen

Link to comment
Share on other sites

  • Solution

Hey @CodyHill, first you need to declare your timelines outside the observer, otherwise every time it is activated you will have a new timeline
and then you set pause as default property in the first timeline, so all the timeline tweens are paused.

See the Pen 443a63d77367c077e1e674c7d3726834 by nicofonseca (@nicofonseca) on CodePen

  • Like 3
Link to comment
Share on other sites

Hi @CodyHill :)

 

Welcome to the forum.

 

I'd also point out that GreenSock's ScrollTrigger plugin makes this type of animation much easier.

 

https://greensock.com/docs/v3/Plugins/ScrollTrigger

 

Here's your demo with a quick conversion to ScrollTrigger.

See the Pen 5403206d8e9e3b3b87e18a9eafe1810e by PointC (@PointC) on CodePen

 

Hopefully that helps. Happy tweening and welcome aboard.

:)

 

  • Like 1
Link to comment
Share on other sites

Thank you! But it seems like the skeleton animation does not work.

  tl.from("#skeleton", {
    y: "20%",
    duration: 1
  })

EDITE:  My bad, it works! but starts on refresh not when the intersection is true

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