westures-core 1.0.0 → 1.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -0
- package/README.md +137 -56
- package/dist/index.js +1249 -22
- package/dist/index.js.map +1 -1
- package/package.json +29 -16
- package/src/Gesture.js +7 -7
- package/src/Input.js +9 -2
- package/src/Point2D.js +12 -0
- package/src/Region.js +23 -30
- package/src/Smoothable.js +2 -2
- package/src/State.js +2 -2
- package/src/constants.js +27 -16
- package/src/utils.js +2 -2
- package/.travis.yml +0 -6
package/src/constants.js
CHANGED
|
@@ -6,11 +6,12 @@
|
|
|
6
6
|
* @memberof westures-core
|
|
7
7
|
* @type {string[]}
|
|
8
8
|
*/
|
|
9
|
-
const CANCEL_EVENTS =
|
|
9
|
+
const CANCEL_EVENTS = [
|
|
10
10
|
'blur',
|
|
11
11
|
'pointercancel',
|
|
12
12
|
'touchcancel',
|
|
13
|
-
|
|
13
|
+
'mouseleave',
|
|
14
|
+
];
|
|
14
15
|
|
|
15
16
|
/**
|
|
16
17
|
* List of keyboard events that trigger a restart.
|
|
@@ -18,10 +19,10 @@ const CANCEL_EVENTS = Object.freeze([
|
|
|
18
19
|
* @memberof westures-core
|
|
19
20
|
* @type {string[]}
|
|
20
21
|
*/
|
|
21
|
-
const KEYBOARD_EVENTS =
|
|
22
|
+
const KEYBOARD_EVENTS = [
|
|
22
23
|
'keydown',
|
|
23
24
|
'keyup',
|
|
24
|
-
]
|
|
25
|
+
];
|
|
25
26
|
|
|
26
27
|
/**
|
|
27
28
|
* List of mouse events to listen to.
|
|
@@ -29,11 +30,11 @@ const KEYBOARD_EVENTS = Object.freeze([
|
|
|
29
30
|
* @memberof westures-core
|
|
30
31
|
* @type {string[]}
|
|
31
32
|
*/
|
|
32
|
-
const MOUSE_EVENTS =
|
|
33
|
+
const MOUSE_EVENTS = [
|
|
33
34
|
'mousedown',
|
|
34
35
|
'mousemove',
|
|
35
36
|
'mouseup',
|
|
36
|
-
]
|
|
37
|
+
];
|
|
37
38
|
|
|
38
39
|
/**
|
|
39
40
|
* List of pointer events to listen to.
|
|
@@ -41,11 +42,11 @@ const MOUSE_EVENTS = Object.freeze([
|
|
|
41
42
|
* @memberof westures-core
|
|
42
43
|
* @type {string[]}
|
|
43
44
|
*/
|
|
44
|
-
const POINTER_EVENTS =
|
|
45
|
+
const POINTER_EVENTS = [
|
|
45
46
|
'pointerdown',
|
|
46
47
|
'pointermove',
|
|
47
48
|
'pointerup',
|
|
48
|
-
]
|
|
49
|
+
];
|
|
49
50
|
|
|
50
51
|
/**
|
|
51
52
|
* List of touch events to listen to.
|
|
@@ -53,24 +54,25 @@ const POINTER_EVENTS = Object.freeze([
|
|
|
53
54
|
* @memberof westures-core
|
|
54
55
|
* @type {string[]}
|
|
55
56
|
*/
|
|
56
|
-
const TOUCH_EVENTS =
|
|
57
|
+
const TOUCH_EVENTS = [
|
|
57
58
|
'touchend',
|
|
58
59
|
'touchmove',
|
|
59
60
|
'touchstart',
|
|
60
|
-
]
|
|
61
|
+
];
|
|
61
62
|
|
|
62
63
|
/**
|
|
63
64
|
* List of potentially state-modifying keys.
|
|
65
|
+
* Entries are: ['altKey', 'ctrlKey', 'metaKey', 'shiftKey'].
|
|
64
66
|
*
|
|
65
67
|
* @memberof westures-core
|
|
66
68
|
* @type {string[]}
|
|
67
69
|
*/
|
|
68
|
-
const STATE_KEYS =
|
|
70
|
+
const STATE_KEYS = [
|
|
69
71
|
'altKey',
|
|
70
72
|
'ctrlKey',
|
|
71
73
|
'metaKey',
|
|
72
74
|
'shiftKey',
|
|
73
|
-
]
|
|
75
|
+
];
|
|
74
76
|
|
|
75
77
|
/**
|
|
76
78
|
* List of the 'key' values on KeyboardEvent objects of the potentially
|
|
@@ -79,12 +81,12 @@ const STATE_KEYS = Object.freeze([
|
|
|
79
81
|
* @memberof westures-core
|
|
80
82
|
* @type {string[]}
|
|
81
83
|
*/
|
|
82
|
-
const STATE_KEY_STRINGS =
|
|
84
|
+
const STATE_KEY_STRINGS = [
|
|
83
85
|
'Alt',
|
|
84
86
|
'Control',
|
|
85
87
|
'Meta',
|
|
86
88
|
'Shift',
|
|
87
|
-
]
|
|
89
|
+
];
|
|
88
90
|
|
|
89
91
|
/**
|
|
90
92
|
* The cancel phase.
|
|
@@ -118,6 +120,14 @@ const MOVE = 'move';
|
|
|
118
120
|
*/
|
|
119
121
|
const START = 'start';
|
|
120
122
|
|
|
123
|
+
/**
|
|
124
|
+
* The recognized phases.
|
|
125
|
+
*
|
|
126
|
+
* @memberof westures-core
|
|
127
|
+
* @type {list.<string>}
|
|
128
|
+
*/
|
|
129
|
+
const PHASES = [START, MOVE, END, CANCEL];
|
|
130
|
+
|
|
121
131
|
/**
|
|
122
132
|
* Object that normalizes the names of window events to be either of type start,
|
|
123
133
|
* move, end, or cancel.
|
|
@@ -125,7 +135,7 @@ const START = 'start';
|
|
|
125
135
|
* @memberof westures-core
|
|
126
136
|
* @type {object}
|
|
127
137
|
*/
|
|
128
|
-
const PHASE =
|
|
138
|
+
const PHASE = {
|
|
129
139
|
blur: CANCEL,
|
|
130
140
|
pointercancel: CANCEL,
|
|
131
141
|
touchcancel: CANCEL,
|
|
@@ -141,7 +151,7 @@ const PHASE = Object.freeze({
|
|
|
141
151
|
mousedown: START,
|
|
142
152
|
pointerdown: START,
|
|
143
153
|
touchstart: START,
|
|
144
|
-
}
|
|
154
|
+
};
|
|
145
155
|
|
|
146
156
|
module.exports = {
|
|
147
157
|
CANCEL_EVENTS,
|
|
@@ -159,5 +169,6 @@ module.exports = {
|
|
|
159
169
|
START,
|
|
160
170
|
|
|
161
171
|
PHASE,
|
|
172
|
+
PHASES,
|
|
162
173
|
};
|
|
163
174
|
|
package/src/utils.js
CHANGED
|
@@ -85,10 +85,10 @@ function setDifference(left, right) {
|
|
|
85
85
|
return setFilter(left, element => !right.has(element));
|
|
86
86
|
}
|
|
87
87
|
|
|
88
|
-
module.exports =
|
|
88
|
+
module.exports = {
|
|
89
89
|
angularDifference,
|
|
90
90
|
getPropagationPath,
|
|
91
91
|
setDifference,
|
|
92
92
|
setFilter,
|
|
93
|
-
}
|
|
93
|
+
};
|
|
94
94
|
|