Events

DragOverInfo

Object for storing various event data required by the "whenDraggedOver" puzzle block.
Type:
  • Object
Properties:
Name Type Description
draggedObjName string Name of the currently dragged object.
downX number Mouse or touch event's offsetX coordinate of the point where dragging started.
downY number Mouse or touch event's offsetY coordinate of the point where dragging started.
prevX number Mouse or touch event's offsetX coordinate of the previous point during dragging.
prevY number Mouse or touch event's offsetY coordinate of the previous point during dragging.
currX number Mouse or touch event's offsetX coordinate of the current point during dragging.
currY number Mouse or touch event's offsetY coordinate of the current point during dragging.
isDowned boolean Flag telling if the mouse is already down or the touch already started.
isMoved boolean Flag telling if the mouse or the touch point moved during dragging.
touchId number Identifier of the touch contact point. Used only for touch events.
downPointWorld v3d.Vector3 3D point (world space) on the currently dragged object where dragging started.

areListenersSame(target0, type0, listener0nullable, optionsOrUseCapture0, target1, type1, listener1nullable, optionsOrUseCapture1) → {boolean}

Check whether 2 event listeners are the same or not. NOTE: "capture" is the only option that affects the fact if the listeners are the same or not.
Parameters:
Name Type Attributes Description
target0 EventTarget Event target the first event listener is registered on.
type0 string Event type of the first even listener.
listener0 function <nullable>
Listener object (null, function or an object with a handleEvent() method) of the first event listener.
optionsOrUseCapture0 Object | boolean Event listener options (or the useCapture flag) of the first event listener.
target1 EventTarget Event target the second listener is registered on.
type1 string Event type of the second even listener.
listener1 function <nullable>
Listener object (null, function or an object with a handleEvent() method) of the second event listener.
optionsOrUseCapture1 Object | boolean Event listener options (or the useCapture flag) of the second event listener.
See:
Returns:
Check result.
Type
boolean

bindListener(target, type, listenernullable, optionsOrUseCapture)

Add the specified event listener to the specified event target. Also register it in _pGlob.eventListeners for easier removal further. This function doesn't add the exact same listener if it was already added. NOTE: automatic removal of an event listener via options.once and options.signal is not reflected in _pGlob.eventListeners. In such cases one must call unbindListener() manually to keep _pGlob.eventListeners updated and to avoid potential issues with how the code checks if the given listener already exists in _pGlob.eventListeners or not.
Parameters:
Name Type Attributes Description
target EventTarget Event target.
type string Event type.
listener function <nullable>
Listener object (null, function or an object with a handleEvent() method).
optionsOrUseCapture Object | boolean Event listener options (or the useCapture flag).
See:

createDragOverInfo() → {DragOverInfo}

Create a DragOverInfo object.
Returns:
Newly created DragOverInfo object.
Type
DragOverInfo

getEventFirstTouchId(event) → {number}

Get the identifier of the first touch contact point for the given touch event.
Parameters:
Name Type Description
event TouchEvent Touch event.
Returns:
Identifier of the first touch contact point or -1 if the given event is not TouchEvent.
Type
number

getEventOffsetCoords(event, touchId, dest) → {v3d.Vector2}

Get offset coordinates from the given mouse or touch browser event.
Parameters:
Name Type Description
event MouseEvent | TouchEvent Mouse or touch event.
touchId number Identifier of a particular touch contact point. Used only for touch events.
dest v3d.Vector2 Destination vector.
Returns:
Destination vector filled with the event's offset coordinates.
Type
v3d.Vector2

isChangedTouchOrNotTouchEventAtAll(event, touchId) → {boolean}

Check whether the given touch contact point identifier corresponds to a changed touch (from event.changedTouches) or not. For non-touch events simply returns "true".
Parameters:
Name Type Description
event MouseEvent | TouchEvent Touch or other event.
touchId number Identifier of a particular touch contact point. Used only for touch events.
Returns:
Check result.
Type
boolean

unbindListener(target, type, listenernullable, optionsOrUseCapture)

Remove the specified event listener from the specified event target. Also unregister it from _pGlob.eventListeners.
Parameters:
Name Type Attributes Description
target EventTarget Event target.
type string Event type.
listener function <nullable>
Listener object (null, function or an object with a handleEvent() method).
optionsOrUseCapture Object | boolean Event listener options (or the useCapture flag).
See: