Class: InteractionEvent

PD. InteractionEvent

Defines an abstracted wrapper around system events.

This is needed as not all events have the same properties and methods, but we can be a bit tolerant of things like cancelling default actions and stopping propagation.


new InteractionEvent(event)

Parameters:
Name Type Description
event object

A MouseEvent, TouchEvent or PointerEvent to process.

Author:
  • drajmarsh

Methods


getDragDistanceX()

Returns the total distance dragged in the X-axis since last pointer down.

Returns:

Returns the overall X-axis drag distance, in pixels.

Type
number

getDragDistanceY()

Returns the total distance dragged in the Y-axis since last pointer down.

Returns:

Returns the overall Y-axis drag distance, in pixels.

Type
number

getDragStartPosX()

Returns the X-axis position of the last pointer down.

Returns:

Returns X-axis position, in pixels.

Type
number

getDragStartPosY()

Returns the Y-axis position of the last pointer down.

Returns:

Returns Y-axis position, in pixels.

Type
number

hasMoved( [threshold])

Determines if pointer moved beyond given threshold.

Parameters:
Name Type Argument Description
threshold number <optional>

The number of pixels of tolerance to allow, defaults to (3 + (3 * window.devicePixelRatio)).

Returns:

Returns true if has moved more than threshold in either axis.

Type
boolean

preventDefault()

Tell the user agent that if the event does not get explicitly handled, its default action should not be taken as it normally would be. The event continues to propagate as usual, unless one of its event listeners calls this.stopPropagation() or this.stopImmediatePropagation(), either of which terminates propagation at once.


stopImmediatePropagation()

Prevents other listeners of the same event from being called.

If several listeners are attached to the same element for the same event type, they are called in order in which they have been added. If during one such call, event.stopImmediatePropagation() is called, no remaining listeners will be called.


stopPropagation()

Prevents further propagation of the current event in the capturing and bubbling phases.