Add initial keyboard shortcut support.

This commit is contained in:
Dermot Duffy
2024-06-05 21:44:17 -07:00
parent 904f6d8142
commit 7ab545738d
186 changed files with 9564 additions and 3658 deletions
+14 -4
View File
@@ -92,6 +92,16 @@ class ActionHandler extends HTMLElement implements ActionHandlerInterface {
}
};
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const endTap = (_ev: Event): void => {
this.holdTimer.stop();
if (this.started) {
this.started = false;
fireEvent(element, 'action', { action: 'end_tap' });
}
};
const end = (ev: Event): void => {
const options = element.actionHandlerOptions;
if (!options?.allowPropagation) {
@@ -109,10 +119,7 @@ class ActionHandler extends HTMLElement implements ActionHandlerInterface {
return;
}
this.holdTimer.stop();
this.started = false;
fireEvent(element, 'action', { action: 'end_tap' });
endTap(ev);
if (options?.hasHold && this.held) {
fireEvent(element, 'action', { action: 'hold' });
@@ -147,6 +154,9 @@ class ActionHandler extends HTMLElement implements ActionHandlerInterface {
element.addEventListener('click', end);
element.addEventListener('keyup', handleEnter);
// If the mouse leaves the element, this is considered the end of the interaction.
element.addEventListener('mouseleave', endTap);
}
}