React-color: dragging the mouse on the color panel feels slow and laggy

Created on 29 Jan 2020  路  6Comments  路  Source: casesandberg/react-color

I am using SketchPicker with onChangeCompelete and it feels cursor barely moves when i drag it.

Most helpful comment

@Atmiya735 I changed my implementation to use onChange instead of onChangeComplete and it is not laggy anymore:

<ChromePicker
          color={selectedColor}
          onChange={(color: ColorResult) => setSelectedColor(color.hex)}
        />

All 6 comments

Hello,

I believe you're supposed to use onChange instead of onChangeComplete if you want the smoother drag behaviour.

Indeed its much smoother thanks. But I want to have both smooth dragging and only send the action when the dragging stops

You could use both events, onChange for smooth dragging and onChangeComplete for sending the action.

<ColorPicker 
    onChange={(color) => {handleSmoothChange(color)}} //update in component only like for a button
    onChangeComplete{(color) => {handleFinalSendAction(color)}} //actually send it to DOM
/>

Hello i m using onChange but still its not smooth for me
Please help me out
```
class ColorPickerDemo extends Component {
state = {
background: "#fff"
};

handleChangeComplete = color => {
this.setState({ background: color.hex });
};
render() {
return (
disableAlpha="false"
color={this.state.background}
onChange={this.handleChangeComplete}
/>
);
}
}

@Atmiya735 I changed my implementation to use onChange instead of onChangeComplete and it is not laggy anymore:

<ChromePicker
          color={selectedColor}
          onChange={(color: ColorResult) => setSelectedColor(color.hex)}
        />

@rodrigomf24 thats strange...onChange should be in fact lagging because it fires on each drag event, right?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

redguardtoo picture redguardtoo  路  4Comments

imsheng picture imsheng  路  6Comments

foreverpinetree picture foreverpinetree  路  3Comments

stevenxxiu picture stevenxxiu  路  6Comments

islemaster picture islemaster  路  5Comments