Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Several usability improvements, especially for dragging mouse along colors #42

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

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