Provides a snapshot containing information about a pointer. A Pointer object is immutable — it will not be updated when the pointer's information changes.

Properties

canvasPos: Vec3

Position of the pointer relative to the top left corner of the drawing surface.

down: boolean
id: number

Unique ID for the pointer

isPrimary: boolean
pressure: null | number
screenPos: Vec3

The (x, y) position of the pointer relative to the top-left corner of the visible canvas.

timeStamp: number

Numeric timestamp (milliseconds, as from performance.now()).

Methods

  • Snaps this pointer to the nearest grid point (rounds the coordinates of this pointer based on the current zoom). Returns a new Pointer and does not modify this.

    Parameters

    Returns Pointer

  • Returns a copy of this pointer with a new position. The screen position is determined by the given canvasPos.

    Parameters

    Returns Pointer

  • Returns a copy of this pointer with a changed timestamp.

    Parameters

    • timeStamp: number

    Returns Pointer

  • Create a new Pointer from a point on the canvas. Intended for unit tests.

    Parameters

    • canvasPos: Vec3
    • isDown: boolean
    • viewport: Viewport
    • id: number = 0
    • device: PointerDevice = PointerDevice.Pen
    • isPrimary: boolean = true
    • pressure: null | number = null
    • timeStamp: null | number = null

    Returns Pointer

  • Creates a Pointer from a DOM event. If relativeTo is given, (0, 0) in screen coordinates is considered the top left of relativeTo.

    Parameters

    • evt: PointerEvent
    • isDown: boolean
    • viewport: Viewport
    • OptionalrelativeTo: HTMLElement

    Returns Pointer

  • Create a new Pointer from a point on the screen. Intended for unit tests.

    Parameters

    • screenPos: Vec3
    • isDown: boolean
    • viewport: Viewport
    • id: number = 0
    • device: PointerDevice = PointerDevice.Pen
    • isPrimary: boolean = true
    • pressure: null | number = null
    • timeStamp: null | number = null

    Returns Pointer

OpenSource licenses