new State(x, y, left, middle, right, up, down)
Simple container for properties describing the state of a mouse.
Parameters:
Name | Type | Description |
---|---|---|
x |
Number | The X position of the mouse pointer in pixels. |
y |
Number | The Y position of the mouse pointer in pixels. |
left |
Boolean | Whether the left mouse button is pressed. |
middle |
Boolean | Whether the middle mouse button is pressed. |
right |
Boolean | Whether the right mouse button is pressed. |
up |
Boolean | Whether the up mouse button is pressed (the fourth button, usually part of a scroll wheel). |
down |
Boolean | Whether the down mouse button is pressed (the fifth button, usually part of a scroll wheel). |
Members
down :Boolean
Whether the down mouse button is currently pressed. This is the fifth
mouse button, associated with downward scrolling of the mouse scroll
wheel.
Type:
- Boolean
left :Boolean
Whether the left mouse button is currently pressed.
Type:
- Boolean
middle :Boolean
Whether the middle mouse button is currently pressed.
Type:
- Boolean
right :Boolean
Whether the right mouse button is currently pressed.
Type:
- Boolean
up :Boolean
Whether the up mouse button is currently pressed. This is the fourth
mouse button, associated with upward scrolling of the mouse scroll
wheel.
Type:
- Boolean
x :Number
The current X position of the mouse pointer.
Type:
- Number
y :Number
The current Y position of the mouse pointer.
Type:
- Number
Methods
fromClientPosition(element, clientX, clientY)
Updates the position represented within this state object by the given
element and clientX/clientY coordinates (commonly available within event
objects). Position is translated from clientX/clientY (relative to
viewport) to element-relative coordinates.
Parameters:
Name | Type | Description |
---|---|---|
element |
Element | The element the coordinates should be relative to. |
clientX |
Number | The X coordinate to translate, viewport-relative. |
clientY |
Number | The Y coordinate to translate, viewport-relative. |