Documentation / @debuffjp/input / Pointer
Class: Pointer
Defined in: pointer.ts:35
Unified mouse, touch and pen input via Pointer Events, in logical game coordinates.
x, y, down, pressed and released describe the primary pointer. Edges are latched until endStep(). All active contacts are in touches for multi-touch. The right and middle mouse buttons are in right and middle.
Constructors
Constructor
new Pointer(
element,toLogical):Pointer
Defined in: pointer.ts:125
Parameters
element
HTMLElement
toLogical
Returns
Pointer
Properties
captureWheel
captureWheel:
boolean=false
Defined in: pointer.ts:61
Block the page scrolling while the wheel is over the element (for wheel zoom in embeds). Default false.
down
down:
boolean=false
Defined in: pointer.ts:38
kind
kind:
PointerKind="mouse"
Defined in: pointer.ts:42
What made the latest primary press: "mouse", "touch" or "pen". "mouse" until the first press.
middle
readonlymiddle:ButtonState
Defined in: pointer.ts:59
The middle mouse button (wheel click).
pressed
pressed:
boolean=false
Defined in: pointer.ts:39
released
released:
boolean=false
Defined in: pointer.ts:40
right
readonlyright:ButtonState
Defined in: pointer.ts:57
The right mouse button (or a pen's barrel button reported as one).
touches
readonlytouches:Map<number,TouchPoint>
Defined in: pointer.ts:44
Active contacts keyed by pointerId.
touchesEnded
readonlytouchesEnded:TouchPoint[] =[]
Defined in: pointer.ts:48
Contacts that ended this step, at their last position, cleared by endStep().
touchesStarted
readonlytouchesStarted:TouchPoint[] =[]
Defined in: pointer.ts:46
Contacts that started this step, cleared by endStep(). They are in touches too unless they also ended.
wheel
wheel:
number=0
Defined in: pointer.ts:53
Vertical wheel (or trackpad) scroll over the element this step, in CSS pixels: positive scrolls down. Summed across events and reset by endStep().
wheelX
wheelX:
number=0
Defined in: pointer.ts:55
Horizontal scroll this step, like wheel: positive scrolls right.
x
x:
number=0
Defined in: pointer.ts:36
y
y:
number=0
Defined in: pointer.ts:37
Methods
dispose()
dispose():
void
Defined in: pointer.ts:228
Returns
void
endStep()
endStep():
void
Defined in: pointer.ts:218
Clear edges and the wheel. Call once after each simulation step.
Returns
void
move()
move(
x,y):void
Defined in: pointer.ts:149
Simulate moving the primary pointer.
Parameters
x
number
y
number
Returns
void
press()
press(
x,y,kind?):void
Defined in: pointer.ts:139
Simulate pressing the primary pointer at logical coordinates, by a mouse unless kind says otherwise.
Parameters
x
number
y
number
kind?
PointerKind = "mouse"
Returns
void
pressButton()
pressButton(
button):void
Defined in: pointer.ts:196
Simulate pressing the right or middle button.
Parameters
button
Returns
void
release()
release():
void
Defined in: pointer.ts:155
Simulate releasing the primary pointer.
Returns
void
releaseButton()
releaseButton(
button):void
Defined in: pointer.ts:204
Simulate releasing the right or middle button.
Parameters
button
Returns
void
scroll()
scroll(
dy,dx?):void
Defined in: pointer.ts:212
Simulate scrolling the wheel by dy (and dx) CSS pixels.
Parameters
dy
number
dx?
number = 0
Returns
void
touchEnd()
touchEnd(
id):void
Defined in: pointer.ts:187
Simulate a contact ending. Ending the primary pointer's contact releases it.
Parameters
id
number
Returns
void
touchMove()
touchMove(
id,x,y):void
Defined in: pointer.ts:178
Simulate a contact moving. The primary pointer follows its contact.
Parameters
id
number
x
number
y
number
Returns
void
touchStart()
touchStart(
id,x,y,kind?):void
Defined in: pointer.ts:166
Simulate a contact starting (a finger by default). The first contact while the primary pointer is up also presses it, as real touches do.
Parameters
id
number
x
number
y
number
kind?
PointerKind = "touch"
Returns
void