MCPcopy Create free account
hub / github.com/testing-library/user-event / Pointer

Class Pointer

src/system/pointer/pointer.ts:12–158  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

10}
11
12export class Pointer {
13 constructor(
14 {pointerId, pointerType, isPrimary}: PointerInit,
15 buttons: Buttons,
16 ) {
17 this.pointerId = pointerId
18 this.pointerType = pointerType
19 this.isPrimary = isPrimary
20 this.isMultitouch = !isPrimary
21 this.buttons = buttons
22 }
23 readonly pointerId: number
24 readonly pointerType: string
25 readonly isPrimary: boolean
26 readonly buttons: Buttons
27
28 isMultitouch: boolean = false
29 isCancelled: boolean = false
30 isDown: boolean = false
31 isPrevented: boolean = false
32
33 position: PointerPosition = {}
34
35 init(instance: Instance) {
36 const target = this.getTarget(instance)
37 const [, enter] = getTreeDiff(null, target)
38 const init = this.getEventInit()
39
40 assertPointerEvents(instance, target)
41
42 instance.dispatchUIEvent(target, 'pointerover', init)
43 enter.forEach(el => instance.dispatchUIEvent(el, 'pointerenter', init))
44
45 return this
46 }
47
48 move(instance: Instance, position: PointerPosition) {
49 const prevPosition = this.position
50 const prevTarget = this.getTarget(instance)
51
52 this.position = position
53
54 if (!isDifferentPointerPosition(prevPosition, position)) {
55 return
56 }
57
58 const nextTarget = this.getTarget(instance)
59
60 const init = this.getEventInit(-1)
61
62 const [leave, enter] = getTreeDiff(prevTarget, nextTarget)
63
64 return {
65 leave: () => {
66 if (hasPointerEvents(instance, prevTarget)) {
67 if (prevTarget !== nextTarget) {
68 instance.dispatchUIEvent(prevTarget, 'pointerout', init)
69 leave.forEach(el =>

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected