Jump to content
Search Community

Problem with making a timeline that dynamically animates a different element every repetition, with Vue

Sameh_07 test
Moderator Tag

Go to solution Solved by GreenSock,

Recommended Posts

I'm trying to make a simple slider that animates-in then out one slide after the other according to the currentStep variable, which gets incremented by 1 at the end of every slide, but nonetheless , I end up getting the same slide over and over again and can't figure out why...

 

See the Pen mdmPwMN by samehhashy (@samehhashy) on CodePen

Link to comment
Share on other sites

You're only adding slide 1 to the timeline.

The component mounts - you add the animation for slide one, then on timeline complete you increment the item number but you don't actually add anything else to the timeline.

It's just looping the one slide you've told it to animate.

Link to comment
Share on other sites

2 minutes ago, Cassie said:

You're only adding slide 1 to the timeline.

The component mounts - you add the animation for slide one, then on timeline complete you increment the item number but you don't actually add anything else to the timeline.

It's just looping the one slide you've told it to animate.

What I wanted to do is to repeat the same timeline but for the new slide, hoping that by then the ref would be updated.

Is there something wrong with this logic?

  • Like 1
Link to comment
Share on other sites

That's not how timeline's work - a repeat isn't like a code loop. It's an animation loop.

It's repeating the animation using the element it was instantiated with (slide 1) So it'll just repeat slide 1 forever.

 

If you want to loop through and add the other slides to that timeline you'll need to actually make an if/while/foreach loop

  • Like 1
  • Thanks 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...