Skip to content

Event Methods

Isaac edited this page Oct 12, 2021 · 1 revision

events(types, callback)

The events method can group multiple different events under one umbrella.

types

Event types work like the first parameter you would pass into an event listener method in vanilla JavaScript. You can group multiple events in one call.

// vanilla JS 
document.addEventListener("click", clickEvent);

// Xenium
x().events("click", (e, t) => {});

// grouping multiple events
x().events("click, mousemove, mousedown", (e, t) => {});

types: string

The type of events to perform

callback: function

The callback function can take 2 parameters, the e parameter is the event object. The event object has a couple of extra methods added to it. See below documentation of e.isTarget() and e.isEvent()

Returns - void


e.isTarget(identifier, callback)

The is target method checks to see if the clicked target contains the class or id that was passed into the isTarget method.

identifier: string

The selector identifier of the event target

callback: function

If the identifier has been found this callback function will execute. If this method is not used this method will return a boolean value.

Returns - boolean or void


e.isEvent(eventType, callback)

Executes if the type of event performed is the same as the type of event passed into the isEvent method.

eventType: string

The event type to check for.

callback: function

If the event type has been found this callback function will execute. If this method is not used this method will return a boolean value.

Returns - boolean or void

Clone this wiki locally