Namespace: Events:pause

Events:pause

Source:

Methods

pause(targets, events, handleropt, nullable, pausedopt, nullable) → {Number}

Pauses (a), previously defined, event listener(s), without actually removing anything. Subsequent executions of the handler will not fire, while the handler is paused, which also means, that paused handlers, set up to only fire once, will not self-destroy while being paused.

The definition of targets and events works exactly as in "on" and "once", the only difference being, that the handler is optional in this case, which results in the pausing of all handlers, without targeting a specific one.

To specifically target handlers without a namespace, please use the namespace-string "__default".

Parameters:
Name Type Attributes Default Description
targets EventTarget | Array.<EventTarget>

the target(s) to pause event handlers on

events String | Array.<String>

the event name(s) to pause, can be either a single name or a list of names, each name may also have a namespace, separated by a dot, to target all events/namespaces, you may use ""/".*"

handler function <optional>
<nullable>
null

a specific callback function to pause

paused Boolean <optional>
<nullable>
true

defines if the matched handlers are being paused or resumed

Source:
See:
Throws:
  • error in case no targets are defined

  • error in case no events are defined

  • error in case a defined handler is not a function

  • error in case targets are not all usable event targets

  • error in case delegations are missing viable ancestor targets

Returns:
the number of handlers actually paused by the function call, may also be 0 if nothing matched
Type
Number
Example
pause(buttonElement, 'click');
pause(linkElement, '*.__default');
pause(customEventElement, 'crash');
pause([ancestorElement, 'a'], 'click');
pause([ancestorElement, '.btn[data-foobar="test"]'], '*.delegated', fSpecificHandler);