-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
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
[docs][material-ui] Slider in color customization playground twitches when sliding #42019
Comments
Thanks for reporting this - I think this could be an issue with the playground and not the Slider component itself, as it doesn't repro in the Slider demos here The component for the playground is here - would you be interested in investigating this further? @yassinmars |
Thank you for your response and guidance @mj12albert - yes absolutely i would like to investigate the issue further, i have already located the code for the playground and I'm currently looking through it to pinpoint the exact cause of the twitching issue. I'll share my findings as soon as I have something concrete. |
@mj12albert, I believe I've identified potential areas that could be causing the twitching issue with the Slider component. Here are my key observations: -State Management in handleChangeShade: -Dynamic Styling Calculations: I'm currently exploring optimizations in the handleChangeShade function to reduce the number of state updates and simplify the dynamic style calculations. These changes might help in achieving smoother interactions with the Slider. |
@mj12albert, I've implemented several optimizations based on the initial observation to address the issue. Here are the changes and the solutions i came up with:
I refactored the handleChangeShade function to minimize the number of state updates and potential re-renders. By consolidating the state updates into a single setState call, we reduce the overhead and improve the slider's responsiveness. Here's the revised code snippet:
To further enhance performance, I simplified the Slider's dynamic styling by moving the style calculations outside of the component render method. This approach minimizes recalculations and leverages CSS for better performance. The updated styling I applied is as follows:
I ensured that these changes were integrated smoothly within the colorPicker function, keeping in mind the overall component structure and existing functionality. The focus was on ensuring that the modifications did not introduce any new issues or regressions. |
@yassinmars Thanks for looking into this - would you like you make a PR so we can try out the changes? |
This issue has been closed. If you have a similar problem but not exactly the same, please open a new issue. Note We value your feedback @yassinmars! How was your experience with our support team? |
Steps to reproduce
Link to live example: (required)
slider.problem.issue.mp4
Steps:
1.Go to Settings
2.Click on "Edit documentation colors"
3.Slide the toggle from left to right.
4.Observe the behavior as it passes the 100 and 50 marks and the marks after that.
Current behavior
When sliding the Slider component's toggle from left to right, a noticeable twitch occurs around the 100 and 50 marks.
The marks for A700 and A400 are not displayed when the slider moves from left to right.
These issues do not occur when sliding from right to left.
Expected behavior
The Slider should move smoothly without any twitching at any point along the track.
All marks, including A700 and A400, should be visible when sliding from left to right.
Context
I am attempting to provide a seamless user experience when using the slider. This twitching effect is causing confusion and a less satisfactory user interaction.
Your environment
npx @mui/envinfo
Search keywords: Slider, twitch, A700, A400, marks, animation issue
The text was updated successfully, but these errors were encountered: