Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Mouse

A class that tracks the mouse position, wheel, and buttons.

Hierarchy

  • Mouse

Index

Constructors

constructor

  • new Mouse(element?: HTMLElement): Mouse
  • Parameters

    • Default value element: HTMLElement = document.body

    Returns Mouse

Properties

Private buttons

buttons: Set<number> = new Set<number>()

deltaX

deltaX: number = 0

The x distance moved since the previous mouse event.

deltaY

deltaY: number = 0

The y distance moved since the previous mouse event.

Readonly element

element: HTMLElement

The element that the mouse position is calculated relative to.

wheelX

wheelX: number = 0

The x distanced scrolled during the current wheel event.

wheelY

wheelY: number = 0

The y distance scrolled during the current wheel event.

wheelZ

wheelZ: number = 0

The z distance scrolled (zoomed) during the current wheel event.

x

x: number = NaN

The x coordinate of the mouse relative to element.

y

y: number = NaN

The x coordinate of the mouse relative to element.

Methods

addEventListeners

  • addEventListeners(): void
  • Add the appropriate event listeners for the mouse.

    This method is called automatically when a mouse object is created.

    Returns void

Private handleEvent

  • handleEvent(event: MouseEvent): void
  • internal

    Parameters

    • event: MouseEvent

    Returns void

isDown

  • isDown(button?: number): boolean
  • Check whether one of the mouse buttons is down.

    Parameters

    • Default value button: number = MOUSE_BUTTON_LEFT

    Returns boolean

removeEventListeners

  • removeEventListeners(): void
  • Remove the event listeners for the mouse. This can be used to stop the mouse processing events.

    Returns void

Generated using TypeDoc