(pointerName: string, pointerType: string, buttons: Buttons)
| 33 | private nextId = 1 |
| 34 | |
| 35 | new(pointerName: string, pointerType: string, buttons: Buttons) { |
| 36 | const isPrimary = |
| 37 | pointerType !== 'touch' || |
| 38 | !Object.values(this.registry).some( |
| 39 | p => p.pointerType === 'touch' && !p.isCancelled, |
| 40 | ) |
| 41 | |
| 42 | if (!isPrimary) { |
| 43 | Object.values(this.registry).forEach(p => { |
| 44 | if (p.pointerType === pointerType && !p.isCancelled) { |
| 45 | p.isMultitouch = true |
| 46 | } |
| 47 | }) |
| 48 | } |
| 49 | |
| 50 | this.registry[pointerName] = new Pointer( |
| 51 | { |
| 52 | pointerId: this.nextId++, |
| 53 | pointerType, |
| 54 | isPrimary, |
| 55 | }, |
| 56 | buttons, |
| 57 | ) |
| 58 | |
| 59 | return this.registry[pointerName] |
| 60 | } |
| 61 | |
| 62 | get(pointerName: string) { |
| 63 | if (!this.has(pointerName)) { |
no test coverage detected