Skip to content
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

currentTime has no effect when animation is in the finished state #47

Open
ofirdev opened this issue Nov 3, 2015 · 0 comments
Open

Comments

@ofirdev
Copy link

ofirdev commented Nov 3, 2015

I'm trying to reset an animation by setting the currentTime to 0.
When the animation is in the finished state, currentTime doesn't update the animation.
Only when calling animation.pause() before setting animation.currentTime I can see it changes.

document.timeline.getAnimations() also ignores animations in the finished state.
It will be useful to be able to get all animations for the same use case above to reset all animations in a timeline/page.

Tested with web-animations-next from the 2.1.3 release.

Might be related to
web-animations/web-animations-next#369

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>web animations</title>
    <script>
        var animation;

        var startAnimation = function() {
            var el = document.querySelector('#elem');
            var effect = new KeyframeEffect(el, [
                {opacity: 0},
                {opacity: 1.0}
            ], {
                duration: 2000,
                fill: 'forwards'
            });
            animation = new Animation(effect, document.timeline);
            animation.play();
            };

        var resetAnimation = function() {
            //animation.pause();
            animation.currentTime = 0;
        };
    </script>
</head>
<body>
    <div id="elem" style="width:150px; opacity: 0;">Element</div>
    <button onClick="startAnimation()">Start Animation</button>
    <button onClick="resetAnimation()">Reset Animation</button>
    <script type="text/javascript" src="web-animations-next.min.js"></script>
</body>
</html>
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

2 participants