-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
perf: improve pane dragging render performance #5312
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
base: main
Are you sure you want to change the base?
Conversation
|
|
Thanks! This is interesting and we will have a look! |
Hello, how is it going? I have a project that is troubled by this problem. I hope to solve this problem as soon as possible. |
|
Unfortunately this would be a breaking change. Some users might use the classes to change the cursor or do other things. We will have another look this week! |
Hi, I found another way to solve this problem: instead of changing the DOM, provide a new prop: paneClassName to override the className of the Pane component, which can avoid breaking changes. What do you think? |
|
I am not sure if I understand that solution. How would it solve the issue? Can't you overwrite the existing styles if you don't want to change the cursor? |
Sorry, I provided some misleading information. In fact, the style recalculation here is because the class attribute of the pane element is changed, and the descendant elements need to be recalculated. Even if its style is overwritten to keep it consistent, the style recalculation still occurs. At present, it seems that the only way to avoid it is to keep the class of the pane element unchanged. This is what I actually did in my PR |
|
Thanks again! I put it on the React Flow 13 list since it's a breaking change. |
Currently, when dragging/clicking a pane, the pane element will add a
draggingclass to change the cursor style property from grab to grabbing. As the number of nodes (in other words: the amount of DOM) increases, the time it takes to recalculate the style increases, especially on Chromium-based browsers. There is a known chromium issue here that reveals that modifying the cursor style can cause this problem: https://issues.chromium.org/issues/40493007So I applied this style change to a single div to avoid recalculating styles for a large number of elements.
This might help resolve the issue: #4527