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

[FEATURE] Remove persisted styles when calling cancel. #2948

Open
siaikin opened this issue Dec 18, 2024 · 1 comment
Open

[FEATURE] Remove persisted styles when calling cancel. #2948

siaikin opened this issue Dec 18, 2024 · 1 comment
Labels
feature New feature or request

Comments

@siaikin
Copy link

siaikin commented Dec 18, 2024

Is your feature request related to a problem? Please describe.
In some situation I need to stop animating an element from running animation and remove all animation effects. Make it look like the animation never ran.

I see that motion does style persistence automatically internally. But the cancel interface only calls the WAAPI interface without deleting the style.

cancel() {
const { resolved } = this
if (!resolved) return
resolved.animation.cancel()
}

Describe the solution you'd like
I want the cancel interface

  1. Ability to remove internally set styles together.
  2. Alternatively, use the style override of the initial state.

Describe alternatives you've considered
Another solution is that the stop interface no longer checks the value of time, so I can achieve the goal by setting time = 0 and then calling the stop interface.

const animaion = animate();

await animation;

animation.time = 0;
animation.stop();

Additional context
My temporary solution was to manually remove the style on the element using element.style.cssText = ''.

@siaikin siaikin added the feature New feature or request label Dec 18, 2024
@ssijak
Copy link

ssijak commented Dec 18, 2024

I have an issue that is somewhat similar. In version 10 with motion, when I used currentTime=0 and pause() it would commit the initial look to the screen. With 11 it does not. I can't replicate that behavior. And cancel() behaves weirdly where it messes up how animation is executed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants