Advertisement
jargon

Roe2js :: Listeners

May 31st, 2024
577
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function attachListeners(id) {
  2.     const elements = document.querySelectorAll(`.${id}`);
  3.  
  4.     elements.forEach(element => {
  5.         switch(id) {
  6.             case 'view':
  7.                 element.addEventListener('mousemove', handleViewPortalHover);
  8.                 element.addEventListener('mouseover', handleViewPortalHover);
  9.                 element.addEventListener('click', handleViewPortalClick);
  10.                 break;
  11.             case 'tray':
  12.                 element.addEventListener('mousemove', handleTrayPortalHover);
  13.                 element.addEventListener('mouseover', handleTrayPortalHover);
  14.                 element.addEventListener('click', handleTrayPortalClick);
  15.                 break;
  16.             case 'viewframe':
  17.                 element.addEventListener('click', handleViewFrameClick);
  18.                 break;
  19.         }
  20.     });
  21. }
  22.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement