Event.bind
Event.bind(target: Element, event: string, handler: (event: Event) => void, options?: listenerOptions)
The event adds handler for the specified event. The handler will be called each time, when the event occurs. The function's third parameter can contain an object determining event handler properties.
const listenerOptions = { capture?: boolean, once?: boolean, passive?: boolean, } import {Event} from 'main.core'; const button = document.querySelector('.ui-btn'); Event.bind(button, 'click', (event) => { // ... });
Adding nonblocking handler.
import {Event} from 'main.core'; Event.bind(window, 'scroll', scrollHandler, {passive: true});
Such handler will not block performance of default action. In this case, page redrawing during scrolling will be performed immediately, without waiting for finalized handler. Such handler ignores all calls of event.preventDefault().
© «Bitrix24», 2001-2024