File tree 1 file changed +21
-0
lines changed
1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -166,6 +166,27 @@ observerCallback()
166
166
resizeObserver .observe (document .body )
167
167
```
168
168
169
+ ### Listen to input external ` value ` changes
170
+
171
+ If your <input > element's value property might change by means other than this color picker component,
172
+ then it is advisable to periodically check and match the color picker's internal value to the input's value.
173
+
174
+ ``` js
175
+ import ColorPicker , {any_to_hex } from ' @yaireo/color-picker'
176
+
177
+ const colorInput = document .querySelector (' input' )
178
+ const cPicker = new ColorPicker (... )
179
+ const VALUE_CHANGE_SAMPLING_DURATION = 1000
180
+
181
+ setInterval (() => {
182
+ const inputValue = any_to_hex (colorInput .value )
183
+ const pickerValue = any_to_hex (cPicker .CSSColor )
184
+
185
+ if (pickerValue != inputValue)
186
+ cPicker .setColor (inputValue)
187
+ }, VALUE_CHANGE_SAMPLING_DURATION );
188
+ ```
189
+
169
190
### Helper methods exported alongside the * default* ` ColorPicker `
170
191
171
192
You can’t perform that action at this time.
0 commit comments