Namespace: CB_Pointer

CB_Pointer

Static class to manage the pointer, using the Pointer API if available and falling back to internal emulation otherwise. It will return itself if it is tried to be instantiated.

Source:

Methods


<static> normalizeEvent(e) → {Event}

Tries to return the given pointer event with some properties normalized (since different clients can use different values) and perhaps some new properties added (in the case they were missing), when possible. The new attached methods and properties may include polyfills, etc. It also calls the CB_Events.normalize function internally. Some properties added or affected could be "POINTER_TYPE_TOUCH", "POINTER_TYPE_MOUSE", "POINTER_TYPE_PEN", "pointerId", "pointerType", "pressure", "tangentialPressure", "tiltX", "tiltY", "width", "height", "currentTarget", "isPrimary", "twist", etc.

Parameters:
Name Type Description
e Event

Pointer event object. If not provided, it will use the value of "event", "window.event", "Event" or an empty object ("{}").

Source:
To Do:
  • Think about using Object.defineProperty with "writable: true" as option to prevent some web clients problems that have read only properties.
  • Maybe e.width and e.height should be both 1 as default (?).
Returns:

Returns the pointer event object normalized.

Type
Event

<static> onCancel(callbackFunction [, keepOldFunction] [, useCapture] [, target])

Sets a function to execute when the "onPointerCancel" event is fired or removes it. More information: Pointer events.

Parameters:
Name Type Argument Default Description
callbackFunction function | null

The function (event listener) that we want to execute when the event is fired. The first and unique parameter received for this function will be the event object (already normalized by the CB_Pointer.normalizeEvent function). If a null value is used, the event will be removed.

keepOldFunction boolean <optional>
true

Defines whether we want to keep any possible previous event listener for the same target and event name or not.

useCapture boolean <optional>
false

Defines whether the event we want to add will use capture or not. This parameter will be effective only if the current client supports the addEventListener method and will be used as its third parameter.

target Object <optional>
document

The target where we want to attach the event listener.

Source:

<static> onDown(callbackFunction [, keepOldFunction] [, useCapture] [, target])

Sets a function to execute when the "onPointerDown" event is fired or removes it. More information: Pointer events.

Parameters:
Name Type Argument Default Description
callbackFunction function | null

The function (event listener) that we want to execute when the event is fired. The first and unique parameter received for this function will be the event object (already normalized by the CB_Pointer.normalizeEvent function). If a null value is used, the event will be removed.

keepOldFunction boolean <optional>
true

Defines whether we want to keep any possible previous event listener for the same target and event name or not.

useCapture boolean <optional>
false

Defines whether the event we want to add will use capture or not. This parameter will be effective only if the current client supports the addEventListener method and will be used as its third parameter.

target Object <optional>
document

The target where we want to attach the event listener.

Source:

<static> onEnter(callbackFunction [, keepOldFunction] [, useCapture] [, target])

Sets a function to execute when the "onPointerEnter" event is fired or removes it. More information: Pointer events.

Parameters:
Name Type Argument Default Description
callbackFunction function | null

The function (event listener) that we want to execute when the event is fired. The first and unique parameter received for this function will be the event object (already normalized by the CB_Pointer.normalizeEvent function). If a null value is used, the event will be removed.

keepOldFunction boolean <optional>
true

Defines whether we want to keep any possible previous event listener for the same target and event name or not.

useCapture boolean <optional>
false

Defines whether the event we want to add will use capture or not. This parameter will be effective only if the current client supports the addEventListener method and will be used as its third parameter.

target Object <optional>
document

The target where we want to attach the event listener.

Source:

<static> onGotPointCapture(callbackFunction [, keepOldFunction] [, useCapture] [, target])

Sets a function to execute when the "onGotPointerCapture" event is fired or removes it. More information: Pointer events.

Parameters:
Name Type Argument Default Description
callbackFunction function | null

The function (event listener) that we want to execute when the event is fired. The first and unique parameter received for this function will be the event object (already normalized by the CB_Pointer.normalizeEvent function). If a null value is used, the event will be removed.

keepOldFunction boolean <optional>
true

Defines whether we want to keep any possible previous event listener for the same target and event name or not.

useCapture boolean <optional>
false

Defines whether the event we want to add will use capture or not. This parameter will be effective only if the current client supports the addEventListener method and will be used as its third parameter.

target Object <optional>
document

The target where we want to attach the event listener.

Source:

<static> onLeave(callbackFunction [, keepOldFunction] [, useCapture] [, target])

Sets a function to execute when the "onPointerLeave" event is fired or removes it. More information: Pointer events.

Parameters:
Name Type Argument Default Description
callbackFunction function | null

The function (event listener) that we want to execute when the event is fired. The first and unique parameter received for this function will be the event object (already normalized by the CB_Pointer.normalizeEvent function). If a null value is used, the event will be removed.

keepOldFunction boolean <optional>
true

Defines whether we want to keep any possible previous event listener for the same target and event name or not.

useCapture boolean <optional>
false

Defines whether the event we want to add will use capture or not. This parameter will be effective only if the current client supports the addEventListener method and will be used as its third parameter.

target Object <optional>
document

The target where we want to attach the event listener.

Source:

<static> onLostPointCapture(callbackFunction [, keepOldFunction] [, useCapture] [, target])

Sets a function to execute when the "onLostPointerCapture" event is fired or removes it. More information: Pointer events.

Parameters:
Name Type Argument Default Description
callbackFunction function | null

The function (event listener) that we want to execute when the event is fired. The first and unique parameter received for this function will be the event object (already normalized by the CB_Pointer.normalizeEvent function). If a null value is used, the event will be removed.

keepOldFunction boolean <optional>
true

Defines whether we want to keep any possible previous event listener for the same target and event name or not.

useCapture boolean <optional>
false

Defines whether the event we want to add will use capture or not. This parameter will be effective only if the current client supports the addEventListener method and will be used as its third parameter.

target Object <optional>
document

The target where we want to attach the event listener.

Source:

<static> onMove(callbackFunction [, keepOldFunction] [, useCapture] [, target])

Sets a function to execute when the "onPointerMove" event is fired or removes it. More information: Pointer events.

Parameters:
Name Type Argument Default Description
callbackFunction function | null

The function (event listener) that we want to execute when the event is fired. The first and unique parameter received for this function will be the event object (already normalized by the CB_Pointer.normalizeEvent function). If a null value is used, the event will be removed.

keepOldFunction boolean <optional>
true

Defines whether we want to keep any possible previous event listener for the same target and event name or not.

useCapture boolean <optional>
false

Defines whether the event we want to add will use capture or not. This parameter will be effective only if the current client supports the addEventListener method and will be used as its third parameter.

target Object <optional>
document

The target where we want to attach the event listener.

Source:

<static> onOut(callbackFunction [, keepOldFunction] [, useCapture] [, target])

Sets a function to execute when the "onPointerOut" event is fired or removes it. More information: Pointer events.

Parameters:
Name Type Argument Default Description
callbackFunction function | null

The function (event listener) that we want to execute when the event is fired. The first and unique parameter received for this function will be the event object (already normalized by the CB_Pointer.normalizeEvent function). If a null value is used, the event will be removed.

keepOldFunction boolean <optional>
true

Defines whether we want to keep any possible previous event listener for the same target and event name or not.

useCapture boolean <optional>
false

Defines whether the event we want to add will use capture or not. This parameter will be effective only if the current client supports the addEventListener method and will be used as its third parameter.

target Object <optional>
document

The target where we want to attach the event listener.

Source:

<static> onOver(callbackFunction [, keepOldFunction] [, useCapture] [, target])

Sets a function to execute when the "onPointerOver" event is fired or removes it. More information: Pointer events.

Parameters:
Name Type Argument Default Description
callbackFunction function | null

The function (event listener) that we want to execute when the event is fired. The first and unique parameter received for this function will be the event object (already normalized by the CB_Pointer.normalizeEvent function). If a null value is used, the event will be removed.

keepOldFunction boolean <optional>
true

Defines whether we want to keep any possible previous event listener for the same target and event name or not.

useCapture boolean <optional>
false

Defines whether the event we want to add will use capture or not. This parameter will be effective only if the current client supports the addEventListener method and will be used as its third parameter.

target Object <optional>
document

The target where we want to attach the event listener.

Source:

<static> onUp(callbackFunction [, keepOldFunction] [, useCapture] [, target])

Sets a function to execute when the "onPointerUp" event is fired or removes it. More information: Pointer events.

Parameters:
Name Type Argument Default Description
callbackFunction function | null

The function (event listener) that we want to execute when the event is fired. The first and unique parameter received for this function will be the event object (already normalized by the CB_Pointer.normalizeEvent function). If a null value is used, the event will be removed.

keepOldFunction boolean <optional>
true

Defines whether we want to keep any possible previous event listener for the same target and event name or not.

useCapture boolean <optional>
false

Defines whether the event we want to add will use capture or not. This parameter will be effective only if the current client supports the addEventListener method and will be used as its third parameter.

target Object <optional>
document

The target where we want to attach the event listener.

Source:

<static> setPointerEventsProperty(element, value [, important])

Sets the desired value for the CSS' style pointer-events property of a given element.

Parameters:
Name Type Argument Default Description
element Element

Element whose CSS' style "pointer-events" property we want to edit.

value string

CSS code for the CSS' style "pointer-events" property.

important boolean <optional>
false

If set to true, it will add the " !important" text to the "pointer-events" property.

Source: