UNPKG

1.46 kBTypeScriptView Raw
1/**
2 * This class listens to events on the document and then updates a react
3 * component through callbacks.
4 * Please note that captureMouseMove must be called in
5 * order to initialize listeners on mousemove and mouseup.
6 * releaseMouseMove must be called to remove them. It is important to
7 * call releaseMouseMoves since mousemove is expensive to listen to.
8 */
9declare class DOMMouseMoveTracker {
10 // eslint-disable-next-line @typescript-eslint/ban-types
11 constructor(onMove: Function, onMoveEnd: Function, domNode: HTMLElement);
12 /**
13 * This is to set up the listeners for listening to mouse move
14 * and mouse up signaling the movement has ended. Please note that these
15 * listeners are added at the document.body level. It takes in an event
16 * in order to grab inital state.
17 */
18
19 captureMouseMoves(event: object): void;
20
21 /**
22 * These releases all of the listeners on document.body.
23 */
24 releaseMouseMoves(): void;
25
26 /**
27 * Returns whether or not if the mouse movement is being tracked.
28 */
29 isDragging(): boolean;
30
31 /**
32 * Calls onMove passed into constructor and updates internal state.
33 */
34 _onMouseMove(
35 /*object*/
36 event: object,
37 ): void;
38
39 _didMouseMove(): void;
40
41 /**
42 * Calls onMoveEnd passed into constructor and updates internal state.
43 */
44 _onMouseUp(): void;
45}
46
47declare namespace DOMMouseMoveTracker {}
48
49export = DOMMouseMoveTracker;