MCPcopy
hub / github.com/Splidejs/splide / bind

Function bind

src/js/constructors/EventBinder/EventBinder.ts:52–67  ·  view source on GitHub ↗

* Listens to native events. * - `destroy()` can unsubscribe all events. * - In IE, mediaQueryList does not inherit EventTarget, * and only supports deprecated `addListener` and `removeListener`. * * @link https://developer.mozilla.org/en-US/docs/Web/API/MediaQueryList/addListener

(
    targets: EventTargets,
    events: string | string[],
    callback: AnyFunction,
    options?: AddEventListenerOptions
  )

Source from the content-addressed store, hash-verified

50 * @param options - Optional. The options to pass to the `addEventListener` function.
51 */
52 function bind(
53 targets: EventTargets,
54 events: string | string[],
55 callback: AnyFunction,
56 options?: AddEventListenerOptions
57 ): void {
58 forEachEvent( targets, events, ( target, event, namespace ) => {
59 const isEventTarget = 'addEventListener' in target;
60 const remover = isEventTarget
61 ? target.removeEventListener.bind( target, event, callback, options )
62 : target[ 'removeListener' ].bind( target, callback );
63
64 isEventTarget ? target.addEventListener( event, callback, options ) : target[ 'addListener' ]( callback );
65 listeners.push( [ target, event, namespace, callback, remover ] );
66 } );
67 }
68
69 /**
70 * Removes the event handler.

Callers 15

loadFunction · 0.85
listenFunction · 0.85
createPaginationFunction · 0.85
mountFunction · 0.85
mountFunction · 0.85
onPointerDownFunction · 0.85
listenFunction · 0.85
observeImagesFunction · 0.85
listenFunction · 0.85
mountFunction · 0.85
initFunction · 0.85
mountFunction · 0.85

Calls 2

forEachEventFunction · 0.85
bindMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…