events.js
Members
inner _supportsPassive
[utils/events.js](https://docs.videojs.com/utils_events.js.html)
, [line 215](https://docs.videojs.com/utils_events.js.html#line215)
Whether passive event listeners are supported
inner, constant passiveEvents
[utils/events.js](https://docs.videojs.com/utils_events.js.html)
, [line 240](https://docs.videojs.com/utils_events.js.html#line240)
Touch events Chrome expects to be passive
Methods
static any(elem, type, fn)
[utils/events.js](https://docs.videojs.com/utils_events.js.html)
, [line 512](https://docs.videojs.com/utils_events.js.html#line512)
Trigger a listener only once and then turn if off for all configured events
Parameters:
Name | Type | Description |
---|---|---|
elem | Element | Object | Element or object to bind to. |
type | string | Array.<string> | Name/type of event |
fn | Event~EventListener | Event listener function |
static fixEvent(event) → {Object}
[utils/events.js](https://docs.videojs.com/utils_events.js.html)
, [line 89](https://docs.videojs.com/utils_events.js.html#line89)
Fix a native event to have standard property values
Parameters:
Name | Type | Description |
---|---|---|
event | Object | Event object to fix. |
Returns:
Object -
Fixed event object.
static off(elem, typeopt, fnopt)
[utils/events.js](https://docs.videojs.com/utils_events.js.html)
, [line 346](https://docs.videojs.com/utils_events.js.html#line346)
Removes event listeners from an element
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
elem | Element | Object | Object to remove listeners from. | |
type | string | Array.<string> | <optional> | Type of listener to remove. Don’t include to remove all events from element. |
fn | EventTarget~EventListener | <optional> | Specific listener to remove. Don’t include to remove listeners for an event type. |
static on(elem, type, fn)
[utils/events.js](https://docs.videojs.com/utils_events.js.html)
, [line 260](https://docs.videojs.com/utils_events.js.html#line260)
Add an event listener to element It stores the handler function in a separate cache object and adds a generic handler to the element’s event, along with a unique id (guid) to the element.
Parameters:
Name | Type | Description |
---|---|---|
elem | Element | Object | Element or object to bind listeners to |
type | string | Array.<string> | Type of event to bind to. |
fn | EventTarget~EventListener | Event listener. |
static one(elem, type, fn)
[utils/events.js](https://docs.videojs.com/utils_events.js.html)
, [line 485](https://docs.videojs.com/utils_events.js.html#line485)
Trigger a listener only once for an event.
Parameters:
Name | Type | Description |
---|---|---|
elem | Element | Object | Element or object to bind to. |
type | string | Array.<string> | Name/type of event |
fn | Event~EventListener | Event listener function |
static trigger(elem, event, hashopt) → {boolean|undefined}
[utils/events.js](https://docs.videojs.com/utils_events.js.html)
, [line 420](https://docs.videojs.com/utils_events.js.html#line420)
Trigger an event for an element
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
elem | Element | Object | Element to trigger an event on | |
event | EventTarget~Event | string | A string (the type) or an event object with a type attribute | |
hash | Object | <optional> | data hash to pass along with the event |
Returns:
boolean | undefined -
Returns the opposite of defaultPrevented
if default was prevented. Otherwise, returns undefined
inner _cleanUpEvents(elem, type)
[utils/events.js](https://docs.videojs.com/utils_events.js.html)
, [line 25](https://docs.videojs.com/utils_events.js.html#line25)
Clean up the listener cache and dispatchers
Parameters:
Name | Type | Description |
---|---|---|
elem | Element | Object | Element to clean up |
type | string | Type of event to clean up |
inner _handleMultipleEvents(fn, elem, type, callback)
[utils/events.js](https://docs.videojs.com/utils_events.js.html)
, [line 73](https://docs.videojs.com/utils_events.js.html#line73)
Loops through an array of event types and calls the requested method for each type.
Parameters:
Name | Type | Description |
---|---|---|
fn | function | The event method we want to use. |
elem | Element | Object | Element or object to bind listeners to |
type | string | Type of event to bind to. |
callback | EventTarget~EventListener | Event listener. |