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

pref: instead of debounce 20ms, using requestIdleCallback to delay calculation #425

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

myNameIsDu
Copy link
Member

No description provided.

@vercel
Copy link

vercel bot commented Apr 24, 2023

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

Name Status Preview Comments Updated (UTC)
rsuite-table ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 25, 2023 2:29am

@codesandbox-ci
Copy link

codesandbox-ci bot commented Apr 25, 2023

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.

Latest deployment of this branch, based on commit 9bc1bba:

Sandbox Source
React Configuration
Vanilla Configuration

if (idleCallbackId) {
window.cancelIdleCallback(idleCallbackId);
}
idleCallbackId = window.requestIdleCallback(deadline => {
Copy link
Member

Choose a reason for hiding this comment

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

Safari browser does not support requestIdleCallback.

idleCallbackId = null;
calculateTableWidth(entries[0].contentRect.width);
} else {
changeTableWidthWhenResize(entries);
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
changeTableWidthWhenResize(entries);
// If there is not enough idle time, try again in a future idle period.
// Use setTimeout to avoid stack overflow if this function is called too frequently.
setTimeout(() => {
changeTableWidthWhenResize(entries);
}, 50);

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.

None yet

2 participants