Skip to content

fix(docs): restart the latest selected playground animation - #1940

Open
nemo-crypto wants to merge 1 commit into
animate-css:mainfrom
nemo-crypto:fix/docs-restart-selected-animation
Open

nemo-crypto wants to merge 1 commit into
animate-css:mainfrom
nemo-crypto:fix/docs-restart-selected-animation

Conversation

@nemo-crypto

Copy link
Copy Markdown

Selecting an animation while another preview is still running leaves both animation classes on the title. CSS source order then determines what plays, rather than the user's latest selection. For example, selecting pulse during the zoomInDown intro keeps playing zoomInDown; selecting bounce while pulse is running also leaves pulse in control. Re-selecting the current animation does not restart it.

Cache the animation classes represented by the list, remove them before each selection, and flush that removal before adding the requested class. This also handles interruption of the intro animation and replay of the same animation. The synchronous layout read is limited to the preview target on an explicit selection, not an animation-frame loop.

Validation:

  • Added tests/playground-restart.js, which uses the actual stylesheet and playground module with real browser CSS animations.
  • The original implementation fails (computed animation remains zoomInDown when pulse is selected).
  • Chromium, Firefox and WebKit pass intro interruption, switching from pulse to bounce, restarting the same animation, and cleanup after animation completion.
  • node --check docs/modules/playground.mjs and git diff --check pass.

Run the optional test after installing @playwright/test and its browsers: node tests/playground-restart.js. No physical devices were tested. This is independent of the keyboard-control change in #1939 and works with the existing span markup.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants