🍄object handler
Last updated
Was this helpful?
Last updated
Was this helpful?
Was this helpful?
JS ⟩ browser ⟩ event ⟩ handler ⟩ register ⟩ object handler
delegate event handling to an object:
elem.addEventListener('click', {
// calls handleEvent(event) in case of an event.
handleEvent(event) { ... } // ⭐️ required method
});
class Menu {
// ⭐️ required method
handleEvent(event) {
switch(event.type) {
case 'mousedown': ...; break;
case 'mouseup' : ...; break