* Initializes the events the modules needs to listen to * It translates the pointer events to me.events * in order to make them pass through the system and to make * this module testable. Then we subscribe this module to the * transformed events. * @private
()
| 40 | * @private |
| 41 | */ |
| 42 | initEvents() { |
| 43 | input.registerPointerEvent("pointerdown", this, (e) => { |
| 44 | emit(DRAGSTART, e, this); |
| 45 | }); |
| 46 | input.registerPointerEvent("pointerup", this, (e) => { |
| 47 | emit(DRAGEND, e, this); |
| 48 | }); |
| 49 | input.registerPointerEvent("pointercancel", this, (e) => { |
| 50 | emit(DRAGEND, e, this); |
| 51 | }); |
| 52 | |
| 53 | this.handlePointerMove = (e) => { |
| 54 | this.dragMove(e); |
| 55 | }; |
| 56 | |
| 57 | this.handleDragStart = (e, draggable) => { |
| 58 | if (draggable === this) { |
| 59 | this.dragStart(e); |
| 60 | } |
| 61 | }; |
| 62 | |
| 63 | this.handleDragEnd = (e, draggable) => { |
| 64 | if (draggable === this) { |
| 65 | this.dragEnd(e); |
| 66 | } |
| 67 | }; |
| 68 | |
| 69 | on(POINTERMOVE, this.handlePointerMove); |
| 70 | on(DRAGSTART, this.handleDragStart); |
| 71 | on(DRAGEND, this.handleDragEnd); |
| 72 | } |
| 73 | |
| 74 | /** |
| 75 | * Gets called when the user starts dragging the entity |