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

feat(Loader): add paused value to the speed property to control the animation pause #3875

Merged
merged 3 commits into from
Jul 12, 2024

Conversation

jpranays
Copy link
Contributor

@jpranays jpranays commented Jul 7, 2024

Description

This PR introduces a new loaderPlayState prop for the Loader spinner component. The loaderPlayState prop accepts two values: "running" and "paused", allowing users to control the play state of the loader animation.

Use Cases

  1. Pause and Resume: In applications with complex loading sequences, it might be necessary to pause the loader animation while certain conditions are being met and resume it afterward.
  2. Accessibility: Users might want to pause animations to reduce distractions or for accessibility reasons.
  3. User Experience: Provide better user experience by controlling the visibility and behavior of the loader based on user interactions.

Implementation Details

  • Added a new loaderPlayState prop to the Loader component, which defaults to "running".
  • Updated the CSS/JS to handle the "running" and "paused" states appropriately.
  • Ensured backward compatibility by setting the default value to "running" so existing implementations are not affected.

Code Example

// Usage Example
<Loader loaderPlayState="paused" />

Copy link

codesandbox bot commented Jul 7, 2024

Review or Edit in CodeSandbox

Open the branch in Web EditorVS CodeInsiders

Open Preview

Copy link

vercel bot commented Jul 7, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
rsuite-nextjs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 10, 2024 5:58am
rsuite-storybook ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 10, 2024 5:58am
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
rsuite-v4 ⬜️ Ignored (Inspect) Visit Preview Jul 10, 2024 5:58am

Copy link

vercel bot commented Jul 7, 2024

Someone is attempting to deploy a commit to the rsuite Team on Vercel.

A member of the Team first needs to authorize it.

Copy link

codesandbox-ci bot commented Jul 7, 2024

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

@simonguo
Copy link
Member

simonguo commented Jul 8, 2024

Hi @jpranays

I suggest adding a paused value to the speed prop to indicate the paused state of the loader.

// speed:  'fast' | 'normal' | 'slow' | 'paused'
<Loader speed="paused" />

@jpranays
Copy link
Contributor Author

jpranays commented Jul 8, 2024

Great idea! I’ll add paused to the speed prop.

@simonguo
Copy link
Member

simonguo commented Jul 8, 2024

Great idea! I’ll add paused to the speed prop.

Also, remember to add a test case for this to ensure it works as expected.
https://github.com/rsuite/rsuite/blob/main/src/Loader/test/LoaderSpec.tsx#L36

@jpranays
Copy link
Contributor Author

jpranays commented Jul 8, 2024

Great idea! I’ll add paused to the speed prop.

Also, remember to add a test case for this to ensure it works as expected. https://github.com/rsuite/rsuite/blob/main/src/Loader/test/LoaderSpec.tsx#L36

PR updated

@simonguo simonguo changed the title Feat:loader-play-state prop added feat(Loader): add paused value to the speed property to control the animation pause Jul 10, 2024
Copy link
Member

@simonguo simonguo left a comment

Choose a reason for hiding this comment

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

@simonguo
Copy link
Member

@jpranays
Copy link
Contributor Author

Jietu20240710-121558-HD.mp4
The paused value doesn't work, check your CSS specificity. You can add an example to the docs to preview it.

https://github.com/rsuite/rsuite/blob/main/docs/pages/components/loader/fragments/speed.md

And the documentation needs to be modified. https://github.com/rsuite/rsuite/blob/main/docs/pages/components/loader/en-US/index.md#loader-1 https://github.com/rsuite/rsuite/blob/main/docs/pages/components/loader/zh-CN/index.md#loader

Seems strange, works fine for me,

Rsuite-loader-doc.mp4
Rsuite-loader-storybook.mp4

Docs have been updated

@jpranays
Copy link
Contributor Author

@simonguo
Copy link
Member

It works now. It didn't work before because of browser cache.

@simonguo simonguo merged commit 85326c5 into rsuite:main Jul 12, 2024
13 checks passed
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