Skip to content

[BUG] Timeline issue, when adding a new animation, it starts from the beginning #742

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
Manuelbaun opened this issue Dec 20, 2020 · 3 comments

Comments

@Manuelbaun
Copy link

Describe the bug
I want to use the timeline and animate my elements, based on some logic. I would run an algorithm, which adds animation to the timeline and in the end, I can play around with a slider and the seek function. The main issue is now, when I add a new animation to the timeline, the timeline animation starts from the beginning of the timeline, and not from the last position.

I added a simple code snippet here, to demonstrate it. The code below, shows the minimum I came up with, that demonstrate that behavior.

To Reproduce

<div class="demo-content timeline-controls-demo">
    <div class="line">
        <div class="small square shadow"></div>
        <div class="small square el"></div>
    </div>
</div>

<script>
    var tl = anime.timeline({
        duration: 500,
        easing: 'easeInOutSine',
    });

    async function move() {
        for (var i = 0; i < 10; i++) {
            // adds some animation to the timeline
            tl.add({
                targets: '.square.el',
                translateX: i * 10,
            });

            // here, I want to await the animation, 
            // before I add a new animation
            await tl.finished
        }
    }
    // starts the function
    move()
</script>

Expected behavior
I thought, that I could simple continue from the point, where the animation finished, but it restarts everytime I add a new animation to the timeline. Even, if I set seek to a specific time, it would restart from the beginning.

Version

  • anime: 3.2.1

Desktop (please complete the following information):

  • OS: Windows
  • Browser [e.g. chrome, firefox]
  • Version [e.g. 22]

Additional context
I need to use await, because I actually do some other logic besides the animation, and I like to synchronize both.

@neurocmd
Copy link

neurocmd commented Apr 6, 2021

I came across the same issue. Are there any workaround?

@Manuelbaun
Copy link
Author

I did work on this in my fork in the feature-continue-branch. You can have a look there. I have also added a markdown file where I describe what I did.

https://github.com/Manuelbaun/anime/blob/feature-continue/changes.md

Maybe @juliangarnier can have a look and if he sees it fit, he could add it to the library.

@neurocmd
Copy link

neurocmd commented Apr 6, 2021

Thanks a lot

@juliangarnier juliangarnier self-assigned this Apr 16, 2025
@juliangarnier juliangarnier added this to the v4.0.2 milestone Apr 16, 2025
@juliangarnier juliangarnier modified the milestones: v4.0.2, v4.0.3 Apr 24, 2025
@juliangarnier juliangarnier changed the title timeline issue, when adding a new animation, it starts from the beginning Timeline issue, when adding a new animation, it starts from the beginning Apr 24, 2025
@juliangarnier juliangarnier changed the title Timeline issue, when adding a new animation, it starts from the beginning [BUG] Timeline issue, when adding a new animation, it starts from the beginning Apr 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants