Pointer herding #2435
mootari
started this conversation in
Show and tell
Pointer herding
#2435
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Thought I'd share a few helper functions that I had created to wrangle multiple pointer transforms in https://observablehq.com/@mootari/github-user-activity. The notebook lets users hover and select rows, all while clicking on links and showing tooltips for events.
Example
Each of the helpers receives the pointer transform as argument, e.g.
Helpers
Prevent stickying
Selectively block
pointerdownevents.Be aware that this blocks the event for all pointer transforms that follow, so it may be more intuitive to use a mark instead:
An alternative approach that I haven't tried yet would be to wrap the event handler itself upon registration.
Ignore stickied marks
Allows tooltips to continue to work while another mark is stickied. Passes a proxy object instead of the root SVG element so that the transform receives a different shared pointer state. Note that using
Proxyinstead would cause illegal invocations.Block value changes
Prevents a pointer transform from changing the Plot's value, e.g. when you have multiple pointers but only one is supposed to drive
plot.value. Works by passing passing a no-op function asdispatchValueto the transform.Beta Was this translation helpful? Give feedback.
All reactions