Skip to content

Instantly share code, notes, and snippets.

@lydemann
Created March 2, 2021 11:57
Show Gist options
  • Select an option

  • Save lydemann/2a5b63d8a68dfe3d4f1a9e68568c4a16 to your computer and use it in GitHub Desktop.

Select an option

Save lydemann/2a5b63d8a68dfe3d4f1a9e68568c4a16 to your computer and use it in GitHub Desktop.
category-transaction-list.component.ts
/*
For avoiding clicks on mouse up after HammerJS long press.
This event is triggered right before (click) to ensure we will not trigger click on long press.
*/
preventClickAfterLongPress(event: MouseEvent) {
const element = event.target as HTMLElement;
// needs to add class directly so it is applied before click event
element.classList.add('prevent-pointer-events');
setTimeout(() => {
element.classList.remove('prevent-pointer-events');
// after 50ms we are sure the "click" event was fired and ignored,
// so we can revert the class name back
}, 50);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment