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

Fix for reverse animation with negative speed #2194

Merged
merged 1 commit into from
Jun 19, 2023
Merged

Conversation

shuangq
Copy link
Contributor

@shuangq shuangq commented Jun 19, 2023

This PR fixes an issue where setting animation.time = animation.duration; animation.speed = -1 finishes the animation, instead of playing it back reversely. A normal animation is considered done when the current time reaches the animation duration. But for reverse animation with negative speed it's the other way around, it's done when the current time reaches 0.

fixes: #2079

if (speed < 0)
startTime = Math.min(timestamp - totalDuration / speed, startTime)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This bit is doing the same thing as the line above, to calibrate the startTime because timestamp can come in lower, but from the reverse direction.

@shuangq shuangq requested a review from mattgperry June 19, 2023 08:09
@shuangq shuangq added the automerge Land this PR label Jun 19, 2023
@mergetron mergetron bot merged commit 6114276 into main Jun 19, 2023
@mergetron mergetron bot deleted the fix/reverse-animation branch June 19, 2023 10:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge Land this PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] setting speed to -1 does not reverse play
2 participants