Defining global event type #14433
Unanswered
geraintluff
asked this question in
Help/Questions
Replies: 1 comment
-
|
The API I'm imagining might look something like this: function registerMove(element, handler) {
let scrollHandler = event => {...}; // calls handler()
element.addEventListener('scroll', scrollHandler);
// other event types
// ...
// returns an un-register callback
return () => {
element.removeEventListener('scroll', scrollHandler);
// etc.
};
}
app.addCustomEvent("move", registerMove); |
Beta Was this translation helpful? Give feedback.
0 replies
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.
-
Is there a way to define a global event type which is translated from a DOM event? For example, I'd like to define
@movesuch that I can write:I'd then have a single global definition for the "move" event which listened for mouse-drag, keyboard and scroll-wheel DOM events, and translated them all to common dx/dy values.
The idea is to concisely provide consistent interactivity across my app, instead of having to separately map drag/keyboard/scroll for each control. Is this possible?
Beta Was this translation helpful? Give feedback.
All reactions