Skip to content

Conversation

@soulmerge
Copy link

I found several small issues while working with the pickers: The color picking process was stopping as soon the mouse pointer left the picker area, which made it very hard to choose colors on edges or corners.

I tried to provide several independent commits, each one just adding a small feature. I also aimed to retain compatibility with ancient IE versions without changing the API behavior.

No functional changes, just removed all whitespace at the end of each
line.
The function was previously registering all events and selectively
performing operations based on a stored state. Changed the behaviour to
register and unregister relevant event listeners on specific occasions.

This not only removes explicit state, but also grants more flexibility,
which will be required for future changes.
Could not pinpoint why, but sometimes a native drag event triggers while
sliding the mouse along the palette and suddenly the whole palette is
being dragged with the mouse.

This commit tries to negate this effect by adding a listener, that
attempts to prevent the `dragstart` event.
It feels more robust if the dragging continues even if the mouse
leaves the area that contains the drag listener. This makes it easier to
pick colors near the edges (particularly near *two* edges, i.e. in the
corners)

For this to work, another listener had to be altered: the `mouseup`
listener is now registered on document.body, instead of the drag area.
It is also unregistered once the dragging is complete.
It is now possible to continue dragging along an edge, even if the mouse
pointer is outside of the target area. This means that dragging along an
edge or into a corner is now absolutely precise.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant