JavaScript Event ListenersΒΆ
Traditionally you might have added an event listener like so
element.addEventListener('click', callback, false)
Where the false
argument relates to event bubbling/capturing. However
this argument can be replaced with an object that gives greater control
over the behaviour
element.addEventListener('click', callback, {
capture: false, // Same as the behaviour as the original bool
once: true, // Run the event once then automatically unregister the listener
passive: false, // If true the function will never call preventDefault()?
})