GithubHelp home page GithubHelp logo

Comments (4)

mj12albert avatar mj12albert commented on May 6, 2024

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

from material-ui.

yassinmars avatar yassinmars commented on May 6, 2024

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.

from material-ui.

yassinmars avatar yassinmars commented on May 6, 2024

@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:
This function updates several state variables simultaneously ([name]Shade, [name], and [name]Input). The frequency and scope of these updates might be causing the component to rerender inefficiently, leading to the twitching observed, particularly near the 100 and 50 marks. Here's code for reference:

image

-Dynamic Styling Calculations:
The Slider's sx property involves dynamic calculations that might be affecting its rendering performance. Reducing complexity in these style calculations could potentially improve performance. Here’s the relevant code:

image

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.

from material-ui.

yassinmars avatar yassinmars commented on May 6, 2024

@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:

  1. Optimized State Management in handleChangeShade:

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:

image

  1. Simplified and Improved Slider Styling:

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:

image

  1. Integrated Changes within colorPicker Function:

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.
Here's how the modified section looks now:

image

from material-ui.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.