JAVASCRIPT   45

prevent-click

Guest on 4th June 2022 01:19:03 AM

  1. /**
  2.  * Stops propagation of click event and removes event listener
  3.  *
  4.  * @private
  5.  * @param {object} event The click event
  6.  */
  7. function preventClickHandler(event) {
  8.     event.stopPropagation();
  9.     document.body.removeEventListener('click', preventClickHandler, true);
  10. }
  11.  
  12. /**
  13.  * Starts listening for click event and prevent propagation
  14.  *
  15.  * @param {object} values Values
  16.  */
  17. export default function preventClick(values) {
  18.     document.body.addEventListener('click', preventClickHandler, true);
  19. }

Raw Paste


Login or Register to edit or fork this paste. It's free.