-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
SensorEvent.ts
130 lines (118 loc) · 2.51 KB
/
SensorEvent.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
import AbstractEvent from 'shared/AbstractEvent';
interface SensorEventData {
clientX: number;
clientY: number;
target: HTMLElement;
container: HTMLElement;
originalSource: HTMLElement;
originalEvent?: Event;
pressure?: number;
}
/**
* Base sensor event
* @class SensorEvent
* @module SensorEvent
* @extends AbstractEvent
*/
export class SensorEvent extends AbstractEvent<SensorEventData> {
/**
* Original browser event that triggered a sensor
* @property originalEvent
* @type {Event}
* @readonly
*/
get originalEvent() {
return this.data.originalEvent;
}
/**
* Normalized clientX for both touch and mouse events
* @property clientX
* @type {Number}
* @readonly
*/
get clientX() {
return this.data.clientX;
}
/**
* Normalized clientY for both touch and mouse events
* @property clientY
* @type {Number}
* @readonly
*/
get clientY() {
return this.data.clientY;
}
/**
* Normalized target for both touch and mouse events
* Returns the element that is behind cursor or touch pointer
* @property target
* @type {HTMLElement}
* @readonly
*/
get target() {
return this.data.target;
}
/**
* Container that initiated the sensor
* @property container
* @type {HTMLElement}
* @readonly
*/
get container() {
return this.data.container;
}
/**
* Draggables original source element
* @property originalSource
* @type {HTMLElement}
* @readonly
*/
get originalSource() {
return this.data.originalSource;
}
/**
* Trackpad pressure
* @property pressure
* @type {Number}
* @readonly
*/
get pressure() {
return this.data.pressure;
}
}
/**
* Drag start sensor event
* @class DragStartSensorEvent
* @module DragStartSensorEvent
* @extends SensorEvent
*/
export class DragStartSensorEvent extends SensorEvent {
static type = 'drag:start';
}
/**
* Drag move sensor event
* @class DragMoveSensorEvent
* @module DragMoveSensorEvent
* @extends SensorEvent
*/
export class DragMoveSensorEvent extends SensorEvent {
static type = 'drag:move';
}
/**
* Drag stop sensor event
* @class DragStopSensorEvent
* @module DragStopSensorEvent
* @extends SensorEvent
*/
export class DragStopSensorEvent extends SensorEvent {
static type = 'drag:stop';
}
/**
* Drag pressure sensor event
* @class DragPressureSensorEvent
* @module DragPressureSensorEvent
* @extends SensorEvent
*/
export class DragPressureSensorEvent extends SensorEvent {
static type = 'drag:pressure';
}