Feature: "Load Control" optimisation #1
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What 👋
Addresses a performance issue where throttling the HEX update would often loose the final change event causing the native color
<input />
and the<Swatch />
UI to become out of sync.Where 🔍
This can be seen by clicking on a
<Swatch />
and "aggressively" stacking update sequences before finishing your color selection. This causes the final swatch selection to be missed by the throttle timeout.Why 🤔
Users deserve a snappy experience and for their selections to be represented accurately within the UI.
How 💡
The 3rd party Lodash Throttle and Debounce dependencies were removed and a custom optimization currently called "Load Control" was created.
This was a React specific integration (although it can be used with vanilla JS too) built around hooks and combines Throttle and Debounce systems within the same system.
"Load Control" allows for spreading the load when dragging the color range slider while still catching the final
<input />
change to keep the UI in sync.Note 📋
I also integrated the "Load Control" into other areas of the application where a Lodash solution was previously in effect:
Demo 📺
Before 👎 🙁
The final color change is NOT caught causing the native UI to show red while the application UI shows blue
After 👍 🙂
Both native and application UI are now in sync, even when "aggressively" dragging the color range slider_.