Skip to content

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

@siaikin

Description

@siaikin

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 = ''.

Metadata

Metadata

Assignees

No one assigned

    Labels

    featureNew feature or requestwontfixThis will not be worked on

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions