@enact/spotlight 3.4.9-experimental-3 → 3.4.9-experimental-7
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/{build/Accelerator → Accelerator}/Accelerator.d.ts +0 -0
- package/Accelerator/Accelerator.js +149 -156
- package/CHANGELOG.md +22 -0
- package/{build/Pause → Pause}/Pause.d.ts +0 -0
- package/Pause/Pause.js +102 -80
- package/Pause/tests/Pause-specs.js +65 -97
- package/SpotlightContainerDecorator/SpotlightContainer.js +175 -140
- package/{build/SpotlightContainerDecorator → SpotlightContainerDecorator}/SpotlightContainerDecorator.d.ts +0 -0
- package/SpotlightContainerDecorator/SpotlightContainerDecorator.js +222 -176
- package/SpotlightContainerDecorator/tests/Element.prototype.closest.js +44 -40
- package/SpotlightContainerDecorator/tests/SpotlightContainerDecorator-specs.js +221 -210
- package/SpotlightContainerDecorator/tests/useSpotlightContainer-specs.js +150 -243
- package/SpotlightContainerDecorator/useSpotlightContainer.js +47 -28
- package/{build/SpotlightRootDecorator → SpotlightRootDecorator}/SpotlightRootDecorator.d.ts +0 -0
- package/SpotlightRootDecorator/SpotlightRootDecorator.js +206 -111
- package/{build/Spottable → Spottable}/Spottable.d.ts +0 -0
- package/Spottable/Spottable.js +448 -410
- package/Spottable/tests/Spottable-specs.js +90 -117
- package/package.json +3 -2
- package/src/container.js +718 -653
- package/src/navigate.js +406 -491
- package/src/pointer.js +86 -78
- package/{build/src → src}/spotlight.d.ts +0 -0
- package/src/spotlight.js +846 -885
- package/src/target.js +448 -474
- package/src/tests/container-specs.js +643 -1251
- package/src/tests/navigate-specs.js +77 -134
- package/src/tests/pointer-specs.js +126 -182
- package/src/tests/spotlight-specs.js +103 -133
- package/src/tests/target-specs.js +597 -960
- package/src/tests/utils.js +89 -67
- package/src/utils.js +155 -158
- package/build/Accelerator/Accelerator.js +0 -162
- package/build/Accelerator/package.json +0 -3
- package/build/CHANGELOG.md +0 -838
- package/build/Pause/Pause.js +0 -164
- package/build/Pause/package.json +0 -3
- package/build/Pause/tests/Pause-specs.js +0 -65
- package/build/README.md +0 -61
- package/build/SpotlightContainerDecorator/SpotlightContainer.js +0 -176
- package/build/SpotlightContainerDecorator/SpotlightContainerDecorator.js +0 -282
- package/build/SpotlightContainerDecorator/package.json +0 -3
- package/build/SpotlightContainerDecorator/tests/Element.prototype.closest.js +0 -45
- package/build/SpotlightContainerDecorator/tests/SpotlightContainerDecorator-specs.js +0 -221
- package/build/SpotlightContainerDecorator/tests/useSpotlightContainer-specs.js +0 -160
- package/build/SpotlightContainerDecorator/useSpotlightContainer.js +0 -133
- package/build/SpotlightRootDecorator/SpotlightRootDecorator.js +0 -189
- package/build/SpotlightRootDecorator/package.json +0 -3
- package/build/Spottable/Spottable.js +0 -491
- package/build/Spottable/package.json +0 -3
- package/build/Spottable/tests/Spottable-specs.js +0 -90
- package/build/package-lock.json +0 -229
- package/build/package.json +0 -28
- package/build/src/container.js +0 -1201
- package/build/src/navigate.js +0 -419
- package/build/src/pointer.js +0 -183
- package/build/src/spotlight.js +0 -896
- package/build/src/target.js +0 -507
- package/build/src/tests/container-specs.js +0 -653
- package/build/src/tests/navigate-specs.js +0 -87
- package/build/src/tests/pointer-specs.js +0 -130
- package/build/src/tests/spotlight-specs.js +0 -112
- package/build/src/tests/target-specs.js +0 -614
- package/build/src/tests/utils.js +0 -104
- package/build/src/utils.js +0 -180
- package/build/styles/debug.less +0 -97
- package/build/styles/mixins.less +0 -63
- package/docs/index.md +0 -364
package/src/pointer.js
CHANGED
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.updatePointerPosition = exports.setPointerMode = exports.notifyPointerMove = exports.notifyKeyDown = exports.hasPointerMoved = exports.getPointerMode = exports.getLastPointerPosition = void 0;
|
|
7
|
+
|
|
8
|
+
var _keymap = require("@enact/core/keymap");
|
|
9
|
+
|
|
10
|
+
var _util = require("@enact/core/util");
|
|
11
|
+
|
|
1
12
|
/**
|
|
2
13
|
* Exports methods and members for working with pointer events in spotlight
|
|
3
14
|
*
|
|
@@ -5,9 +16,6 @@
|
|
|
5
16
|
* @private
|
|
6
17
|
*/
|
|
7
18
|
|
|
8
|
-
import {is} from '@enact/core/keymap';
|
|
9
|
-
import {Job} from '@enact/core/util';
|
|
10
|
-
|
|
11
19
|
/*
|
|
12
20
|
* Whether Spotlight is in pointer mode (as opposed to 5-way mode).
|
|
13
21
|
*
|
|
@@ -15,8 +23,7 @@ import {Job} from '@enact/core/util';
|
|
|
15
23
|
* @default true
|
|
16
24
|
* @private
|
|
17
25
|
*/
|
|
18
|
-
|
|
19
|
-
|
|
26
|
+
var _pointerMode = true;
|
|
20
27
|
/**
|
|
21
28
|
* Sets the current pointer mode
|
|
22
29
|
*
|
|
@@ -24,10 +31,10 @@ let _pointerMode = true;
|
|
|
24
31
|
* @memberof spotlight/pointer
|
|
25
32
|
* @private
|
|
26
33
|
*/
|
|
27
|
-
const setPointerMode = (pointerMode) => {
|
|
28
|
-
_pointerMode = pointerMode;
|
|
29
|
-
};
|
|
30
34
|
|
|
35
|
+
var setPointerMode = function setPointerMode(pointerMode) {
|
|
36
|
+
_pointerMode = pointerMode;
|
|
37
|
+
};
|
|
31
38
|
/**
|
|
32
39
|
* Gets the current pointer mode
|
|
33
40
|
*
|
|
@@ -35,14 +42,18 @@ const setPointerMode = (pointerMode) => {
|
|
|
35
42
|
* @memberof spotlight/pointer
|
|
36
43
|
* @private
|
|
37
44
|
*/
|
|
38
|
-
const getPointerMode = () => {
|
|
39
|
-
return _pointerMode;
|
|
40
|
-
};
|
|
41
45
|
|
|
42
|
-
// Cached pointer position
|
|
43
|
-
let _pointerX = null;
|
|
44
|
-
let _pointerY = null;
|
|
45
46
|
|
|
47
|
+
exports.setPointerMode = setPointerMode;
|
|
48
|
+
|
|
49
|
+
var getPointerMode = function getPointerMode() {
|
|
50
|
+
return _pointerMode;
|
|
51
|
+
}; // Cached pointer position
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
exports.getPointerMode = getPointerMode;
|
|
55
|
+
var _pointerX = null;
|
|
56
|
+
var _pointerY = null;
|
|
46
57
|
/**
|
|
47
58
|
* Returns whether or not the current pointer position matches the provided coordinates
|
|
48
59
|
*
|
|
@@ -53,10 +64,10 @@ let _pointerY = null;
|
|
|
53
64
|
* @memberof spotlight/pointer
|
|
54
65
|
* @private
|
|
55
66
|
*/
|
|
56
|
-
const hasPointerMoved = (x, y) => (
|
|
57
|
-
x !== _pointerX || y !== _pointerY
|
|
58
|
-
);
|
|
59
67
|
|
|
68
|
+
var hasPointerMoved = function hasPointerMoved(x, y) {
|
|
69
|
+
return x !== _pointerX || y !== _pointerY;
|
|
70
|
+
};
|
|
60
71
|
/**
|
|
61
72
|
* Updates the cached pointer position, updating the current pointer mode when the position has
|
|
62
73
|
* changed.
|
|
@@ -68,19 +79,21 @@ const hasPointerMoved = (x, y) => (
|
|
|
68
79
|
* @memberof spotlight/pointer
|
|
69
80
|
* @private
|
|
70
81
|
*/
|
|
71
|
-
const updatePointerPosition = (x, y) => {
|
|
72
|
-
// Chrome emits mousemove on scroll, but client coordinates do not change.
|
|
73
|
-
if (hasPointerMoved(x, y)) {
|
|
74
|
-
setPointerMode(true);
|
|
75
|
-
_pointerX = x;
|
|
76
|
-
_pointerY = y;
|
|
77
82
|
|
|
78
|
-
return true;
|
|
79
|
-
}
|
|
80
83
|
|
|
81
|
-
|
|
82
|
-
};
|
|
84
|
+
exports.hasPointerMoved = hasPointerMoved;
|
|
83
85
|
|
|
86
|
+
var updatePointerPosition = function updatePointerPosition(x, y) {
|
|
87
|
+
// Chrome emits mousemove on scroll, but client coordinates do not change.
|
|
88
|
+
if (hasPointerMoved(x, y)) {
|
|
89
|
+
setPointerMode(true);
|
|
90
|
+
_pointerX = x;
|
|
91
|
+
_pointerY = y;
|
|
92
|
+
return true;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
return false;
|
|
96
|
+
};
|
|
84
97
|
/**
|
|
85
98
|
* Returns the last known position of the pointer
|
|
86
99
|
*
|
|
@@ -88,25 +101,29 @@ const updatePointerPosition = (x, y) => {
|
|
|
88
101
|
* @memberof spotlight/pointer
|
|
89
102
|
* @private
|
|
90
103
|
*/
|
|
91
|
-
const getLastPointerPosition = () => {
|
|
92
|
-
return {
|
|
93
|
-
x: _pointerX,
|
|
94
|
-
y: _pointerY
|
|
95
|
-
};
|
|
96
|
-
};
|
|
97
104
|
|
|
98
|
-
|
|
105
|
+
|
|
106
|
+
exports.updatePointerPosition = updatePointerPosition;
|
|
107
|
+
|
|
108
|
+
var getLastPointerPosition = function getLastPointerPosition() {
|
|
109
|
+
return {
|
|
110
|
+
x: _pointerX,
|
|
111
|
+
y: _pointerY
|
|
112
|
+
};
|
|
113
|
+
}; // 30ms (_pointerHiddenToKeyTimeout) is semi-arbitrary, to account for the time it takes for the
|
|
99
114
|
// following directional key event to fire, and to prevent momentary spotting of the last
|
|
100
115
|
// focused item - needs to be a value large enough to account for the potentially-trailing
|
|
101
116
|
// event, but not too large that another unrelated event can be fired inside the window
|
|
102
|
-
const hidePointerJob = new Job(function (callback) {
|
|
103
|
-
setPointerMode(false);
|
|
104
|
-
if (callback) {
|
|
105
|
-
callback();
|
|
106
|
-
}
|
|
107
|
-
}, 30);
|
|
108
117
|
|
|
109
118
|
|
|
119
|
+
exports.getLastPointerPosition = getLastPointerPosition;
|
|
120
|
+
var hidePointerJob = new _util.Job(function (callback) {
|
|
121
|
+
setPointerMode(false);
|
|
122
|
+
|
|
123
|
+
if (callback) {
|
|
124
|
+
callback();
|
|
125
|
+
}
|
|
126
|
+
}, 30);
|
|
110
127
|
/**
|
|
111
128
|
* Notifies spotlight of a change in the pointer position
|
|
112
129
|
*
|
|
@@ -118,19 +135,19 @@ const hidePointerJob = new Job(function (callback) {
|
|
|
118
135
|
* @memberof spotlight/pointer
|
|
119
136
|
* @private
|
|
120
137
|
*/
|
|
121
|
-
const notifyPointerMove = (current, target, x, y) => {
|
|
122
|
-
const priorPointerMode = getPointerMode();
|
|
123
138
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
139
|
+
var notifyPointerMove = function notifyPointerMove(current, target, x, y) {
|
|
140
|
+
var priorPointerMode = getPointerMode();
|
|
141
|
+
|
|
142
|
+
if (updatePointerPosition(x, y)) {
|
|
143
|
+
// if we're entering pointer mode and the target element isn't within the currently
|
|
144
|
+
// focused element, there may be a new navigable target
|
|
145
|
+
return !priorPointerMode || !current || !current.contains(target);
|
|
146
|
+
} // the pointer hasn't actually moved (surprise!)
|
|
129
147
|
|
|
130
|
-
// the pointer hasn't actually moved (surprise!)
|
|
131
|
-
return false;
|
|
132
|
-
};
|
|
133
148
|
|
|
149
|
+
return false;
|
|
150
|
+
};
|
|
134
151
|
/**
|
|
135
152
|
* Notifies the pointer module of key events. If the pointer should be hidden, a timer is set and
|
|
136
153
|
* `callback` is invoked after the timer has expired and pointer mode has been disabled. For any
|
|
@@ -143,33 +160,24 @@ const notifyPointerMove = (current, target, x, y) => {
|
|
|
143
160
|
* @memberof spotlight/pointer
|
|
144
161
|
* @private
|
|
145
162
|
*/
|
|
146
|
-
const notifyKeyDown = (keyCode, callback) => {
|
|
147
|
-
const palmSystem = window.PalmSystem;
|
|
148
|
-
|
|
149
|
-
// for hide/show pointer events, handle them and return true
|
|
150
|
-
if (is('pointerHide', keyCode)) {
|
|
151
|
-
hidePointerJob.start(callback);
|
|
152
|
-
return true;
|
|
153
|
-
} else if (is('pointerShow', keyCode)) {
|
|
154
|
-
setPointerMode(true);
|
|
155
|
-
return true;
|
|
156
|
-
} else if (
|
|
157
|
-
!is('nonModal', keyCode) &&
|
|
158
|
-
!is('cancel', keyCode) &&
|
|
159
|
-
!(is('enter', keyCode) && palmSystem && palmSystem.cursor && palmSystem.cursor.visibility)
|
|
160
|
-
) {
|
|
161
|
-
setPointerMode(false);
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
return false;
|
|
165
|
-
};
|
|
166
163
|
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
164
|
+
|
|
165
|
+
exports.notifyPointerMove = notifyPointerMove;
|
|
166
|
+
|
|
167
|
+
var notifyKeyDown = function notifyKeyDown(keyCode, callback) {
|
|
168
|
+
var palmSystem = window.PalmSystem; // for hide/show pointer events, handle them and return true
|
|
169
|
+
|
|
170
|
+
if ((0, _keymap.is)('pointerHide', keyCode)) {
|
|
171
|
+
hidePointerJob.start(callback);
|
|
172
|
+
return true;
|
|
173
|
+
} else if ((0, _keymap.is)('pointerShow', keyCode)) {
|
|
174
|
+
setPointerMode(true);
|
|
175
|
+
return true;
|
|
176
|
+
} else if (!(0, _keymap.is)('nonModal', keyCode) && !(0, _keymap.is)('cancel', keyCode) && !((0, _keymap.is)('enter', keyCode) && palmSystem && palmSystem.cursor && palmSystem.cursor.visibility)) {
|
|
177
|
+
setPointerMode(false);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
return false;
|
|
175
181
|
};
|
|
182
|
+
|
|
183
|
+
exports.notifyKeyDown = notifyKeyDown;
|
|
File without changes
|