@enact/ui 4.5.2 → 4.5.3
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/AnnounceDecorator/Announce.js +1 -40
- package/AnnounceDecorator/AnnounceDecorator.js +3 -21
- package/AnnounceDecorator/tests/Announce-specs.js +2 -7
- package/AnnounceDecorator/tests/AnnounceDecorator-specs.js +2 -6
- package/AnnounceDecorator/tests/useAnnounce-specs.js +8 -19
- package/AnnounceDecorator/useAnnounce.js +0 -6
- package/BodyText/BodyText.js +6 -26
- package/BodyText/tests/BodyText-specs.js +0 -19
- package/Button/Button.js +26 -56
- package/Button/tests/Button-specs.js +0 -26
- package/CHANGELOG.md +4 -0
- package/Cancelable/Cancelable.js +8 -47
- package/Cancelable/cancelHandler.js +5 -12
- package/Cancelable/modalHandler.js +3 -11
- package/Cancelable/tests/Cancelable-specs.js +3 -57
- package/Changeable/Changeable.js +2 -34
- package/Changeable/tests/Changeable-specs.js +20 -66
- package/ComponentOverride/ComponentOverride.js +1 -13
- package/FloatingLayer/FloatingLayer.js +17 -73
- package/FloatingLayer/FloatingLayerContainer.js +0 -15
- package/FloatingLayer/FloatingLayerDecorator.js +4 -17
- package/FloatingLayer/Scrim.js +9 -53
- package/FloatingLayer/index.js +0 -4
- package/FloatingLayer/tests/FloatingLayer-specs.js +8 -22
- package/FloatingLayer/tests/Scrim-specs.js +0 -9
- package/FloatingLayer/tests/useFloatingLayerDecorator-specs.js +0 -13
- package/FloatingLayer/useFloatingLayer.js +3 -14
- package/FloatingLayer/useFloatingLayerDecorator.js +3 -11
- package/ForwardRef/ForwardRef.js +1 -10
- package/GridListImageItem/GridListImageItem.js +17 -50
- package/Group/Group.js +4 -35
- package/Group/GroupItem.js +15 -32
- package/Group/tests/Group-specs.js +0 -32
- package/Heading/Heading.js +7 -35
- package/Heading/tests/Heading-specs.js +81 -14
- package/Icon/Icon.js +14 -48
- package/Icon/tests/Icon-specs.js +0 -22
- package/IconButton/IconButton.js +12 -50
- package/IconButton/tests/IconButton-specs.js +0 -7
- package/Image/Image.js +16 -45
- package/Image/tests/Image-specs.js +0 -14
- package/ImageItem/ImageItem.js +17 -46
- package/ImageItem/tests/ImageItem-specs.js +0 -25
- package/Item/Item.js +8 -32
- package/Item/tests/Item-specs.js +0 -24
- package/LabeledIcon/LabeledIcon.js +19 -50
- package/LabeledIcon/tests/LabeledIcon-specs.js +0 -14
- package/Layout/Cell.js +11 -37
- package/Layout/Layout.js +14 -37
- package/Layout/tests/Layout-specs.js +10 -39
- package/Marquee/MarqueeBase.js +29 -63
- package/Marquee/MarqueeController.js +11 -72
- package/Marquee/MarqueeDecorator.js +62 -196
- package/Marquee/index.js +1 -5
- package/Marquee/tests/Marquee-specs.js +258 -87
- package/Measurable/Measurable.js +12 -34
- package/Measurable/tests/Measurable-specs.js +115 -0
- package/Media/Media.js +15 -65
- package/Media/tests/Media-specs.js +168 -0
- package/Placeholder/PlaceholderControllerDecorator.js +7 -43
- package/Placeholder/PlaceholderDecorator.js +7 -38
- package/Placeholder/index.js +0 -4
- package/Placeholder/tests/PlaceholderControllerDecorator-specs.js +25 -0
- package/Placeholder/tests/PlaceholderDecorator-specs.js +28 -0
- package/ProgressBar/ProgressBar.js +13 -44
- package/ProgressBar/tests/ProgressBar-specs.js +0 -17
- package/RadioDecorator/RadioControllerDecorator.js +1 -29
- package/RadioDecorator/RadioDecorator.js +4 -42
- package/RadioDecorator/tests/RadioDecorator-specs.js +12 -49
- package/Repeater/Repeater.js +9 -33
- package/Repeater/tests/Repeater-specs.js +0 -38
- package/Resizable/Resizable.js +7 -35
- package/Resizable/tests/Resizable-specs.js +34 -0
- package/Routable/Link.js +8 -44
- package/Routable/Routable.js +10 -33
- package/Routable/Route.js +0 -6
- package/Routable/Router.js +13 -56
- package/Routable/tests/Routable-specs.js +7 -33
- package/Routable/tests/Router-specs.js +18 -44
- package/Routable/useLink.js +4 -8
- package/Routable/util.js +18 -24
- package/Scrollable/ScrollAnimator.js +49 -65
- package/Scrollable/ScrollThumb.js +2 -13
- package/Scrollable/Scrollable.js +179 -386
- package/Scrollable/ScrollableNative.js +188 -391
- package/Scrollable/Scrollbar.js +28 -100
- package/Scroller/Scroller.js +15 -39
- package/Scroller/ScrollerBasic.js +34 -89
- package/Scroller/UiScrollerBase.js +31 -84
- package/Skinnable/Skinnable.js +11 -38
- package/Skinnable/tests/Skinnable-specs.js +3 -74
- package/Skinnable/tests/useSkins-specs.js +1 -13
- package/Skinnable/tests/util-specs.js +0 -14
- package/Skinnable/useSkins.js +8 -15
- package/Skinnable/util.js +9 -20
- package/Slider/Knob.js +5 -24
- package/Slider/PositionDecorator.js +16 -54
- package/Slider/Slider.js +26 -64
- package/Slider/tests/Slider-specs.js +94 -7
- package/Slider/utils.js +0 -2
- package/SlotItem/SlotItem.js +15 -41
- package/SlotItem/tests/SlotItem-specs.js +0 -5
- package/Slottable/Slottable.js +4 -12
- package/Slottable/tests/Slottable-specs.js +19 -46
- package/Slottable/tests/useSlots-specs.js +27 -65
- package/Slottable/useSlots.js +8 -33
- package/Spinner/Spinner.js +15 -42
- package/Spinner/tests/Spinner-specs.js +0 -15
- package/ToggleIcon/ToggleIcon.js +10 -36
- package/ToggleIcon/tests/ToggleIcon-specs.js +0 -16
- package/ToggleItem/ToggleItem.js +15 -52
- package/ToggleItem/tests/ToggleItem-specs.js +0 -30
- package/Toggleable/Toggle.js +1 -15
- package/Toggleable/Toggleable.js +12 -45
- package/Toggleable/tests/Toggleable-specs.js +28 -96
- package/Toggleable/useToggle.js +3 -19
- package/Touchable/ClickAllow.js +5 -14
- package/Touchable/Drag.js +16 -54
- package/Touchable/Flick.js +11 -42
- package/Touchable/Hold.js +21 -68
- package/Touchable/Touch.js +37 -65
- package/Touchable/Touchable.js +32 -71
- package/Touchable/config.js +8 -22
- package/Touchable/tests/Touchable-specs.js +270 -119
- package/Touchable/tests/useTouch-specs.js +6 -80
- package/Touchable/useTouch.js +17 -34
- package/Transition/Transition.js +37 -118
- package/Transition/tests/Transition-specs.js +20 -60
- package/ViewManager/Arranger.js +10 -22
- package/ViewManager/TransitionGroup.js +31 -106
- package/ViewManager/View.js +35 -91
- package/ViewManager/ViewManager.js +19 -83
- package/ViewManager/tests/View-specs.js +0 -17
- package/ViewManager/tests/ViewManager-specs.js +236 -305
- package/ViewManager/tests/test-utils.js +0 -8
- package/VirtualList/UiVirtualListBase.js +256 -406
- package/VirtualList/VirtualList.js +29 -69
- package/VirtualList/VirtualListBase.js +0 -3
- package/VirtualList/VirtualListBasic.js +270 -428
- package/VirtualList/tests/VirtualList-specs.js +9 -37
- package/internal/IdProvider/IdProvider.js +7 -21
- package/internal/IdProvider/Provider.js +4 -17
- package/internal/IdProvider/tests/IdProvider-specs.js +44 -0
- package/internal/IdProvider/tests/useId-specs.js +7 -22
- package/internal/IdProvider/useId.js +0 -6
- package/internal/Pure/Pure.js +3 -30
- package/internal/Pure/tests/Pure-specs.js +88 -0
- package/internal/localized-fonts/localized-fonts.js +33 -62
- package/internal/localized-fonts/tests/localized-fonts-specs.js +33 -0
- package/internal/selection/selection.js +1 -6
- package/internal/selection/tests/selection-specs.js +6 -4
- package/internal/validators/tests/validators-specs.js +80 -0
- package/internal/validators/validators.js +14 -34
- package/package.json +8 -2
- package/resolution/ResolutionDecorator.js +4 -40
- package/resolution/index.js +0 -7
- package/resolution/resolution.js +42 -80
- package/resolution/tests/ResolutionDecorator-specs.js +4 -11
- package/resolution/tests/resolution-specs.js +2 -2
- package/useControlledState/tests/useControlledState-specs.js +15 -46
- package/useControlledState/useControlledState.js +11 -22
- package/useScroll/ScrollAnimator.js +49 -65
- package/useScroll/Scrollbar.js +22 -58
- package/useScroll/ScrollbarTrack.js +3 -19
- package/useScroll/useScroll.js +267 -454
- package/useScroll/utilDOM.js +8 -14
- package/useScroll/utilEvent.js +0 -4
package/Touchable/Drag.js
CHANGED
|
@@ -4,49 +4,33 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.dragConfigPropType = exports.defaultDragConfig = exports["default"] = exports.Drag = void 0;
|
|
7
|
-
|
|
8
7
|
var _clamp = _interopRequireDefault(require("ramda/src/clamp"));
|
|
9
|
-
|
|
10
8
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
-
|
|
12
9
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
13
|
-
|
|
14
10
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
15
|
-
|
|
16
11
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
17
|
-
|
|
18
12
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
19
|
-
|
|
20
13
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
21
|
-
|
|
22
14
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
23
|
-
|
|
24
15
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
25
|
-
|
|
26
16
|
var Tracking = {
|
|
27
17
|
Untracked: 0,
|
|
28
18
|
Active: 1,
|
|
29
19
|
Paused: 2
|
|
30
20
|
};
|
|
31
|
-
|
|
32
21
|
var Drag = /*#__PURE__*/_createClass(function Drag() {
|
|
33
22
|
var _this = this;
|
|
34
|
-
|
|
35
23
|
_classCallCheck(this, Drag);
|
|
36
|
-
|
|
37
24
|
this.dragConfig = null;
|
|
38
|
-
|
|
39
25
|
this.isDragging = function () {
|
|
40
26
|
return _this.dragConfig != null;
|
|
41
27
|
};
|
|
42
|
-
|
|
43
28
|
this.setContainerBounds = function (node) {
|
|
44
29
|
var _this$dragConfig = _this.dragConfig,
|
|
45
|
-
|
|
46
|
-
|
|
30
|
+
isGlobal = _this$dragConfig.global,
|
|
31
|
+
boxSizing = _this$dragConfig.boxSizing;
|
|
47
32
|
var bounds = null;
|
|
48
33
|
if (!node) return;
|
|
49
|
-
|
|
50
34
|
if (isGlobal) {
|
|
51
35
|
bounds = {
|
|
52
36
|
minX: 0,
|
|
@@ -55,8 +39,9 @@ var Drag = /*#__PURE__*/_createClass(function Drag() {
|
|
|
55
39
|
maxY: window.innerHeight
|
|
56
40
|
};
|
|
57
41
|
} else {
|
|
58
|
-
bounds = node.getBoundingClientRect();
|
|
42
|
+
bounds = node.getBoundingClientRect();
|
|
59
43
|
|
|
44
|
+
// adjust for padding when using content-box
|
|
60
45
|
if (boxSizing === 'content-box') {
|
|
61
46
|
var computedStyle = window.getComputedStyle(node);
|
|
62
47
|
bounds = {
|
|
@@ -67,36 +52,31 @@ var Drag = /*#__PURE__*/_createClass(function Drag() {
|
|
|
67
52
|
};
|
|
68
53
|
}
|
|
69
54
|
}
|
|
70
|
-
|
|
71
55
|
_this.bounds = bounds;
|
|
72
56
|
};
|
|
73
|
-
|
|
74
57
|
this.updatePosition = function (clientX, clientY) {
|
|
75
58
|
var _this$bounds = _this.bounds,
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
59
|
+
maxX = _this$bounds.maxX,
|
|
60
|
+
maxY = _this$bounds.maxY,
|
|
61
|
+
minX = _this$bounds.minX,
|
|
62
|
+
minY = _this$bounds.minY;
|
|
80
63
|
var x = (0, _clamp["default"])(minX, maxX, clientX) - minX;
|
|
81
64
|
var y = (0, _clamp["default"])(minY, maxY, clientY) - minY;
|
|
82
|
-
|
|
83
65
|
if (x !== _this.x || y !== _this.y) {
|
|
84
66
|
_this.x = x;
|
|
85
67
|
_this.y = y;
|
|
86
68
|
return true;
|
|
87
69
|
}
|
|
88
|
-
|
|
89
70
|
return false;
|
|
90
71
|
};
|
|
91
|
-
|
|
92
72
|
this.begin = function (config, _ref, coords, node) {
|
|
93
73
|
var noResume = _ref.noResume,
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
74
|
+
onDrag = _ref.onDrag,
|
|
75
|
+
onDragEnd = _ref.onDragEnd,
|
|
76
|
+
onDragStart = _ref.onDragStart;
|
|
97
77
|
if (!onDrag && !onDragStart && !onDragEnd) return;
|
|
98
78
|
var x = coords.x,
|
|
99
|
-
|
|
79
|
+
y = coords.y;
|
|
100
80
|
_this.tracking = Tracking.Untracked;
|
|
101
81
|
_this.startX = x;
|
|
102
82
|
_this.startY = y;
|
|
@@ -107,35 +87,29 @@ var Drag = /*#__PURE__*/_createClass(function Drag() {
|
|
|
107
87
|
_this.onDrag = onDrag;
|
|
108
88
|
_this.onDragStart = onDragStart;
|
|
109
89
|
_this.onDragEnd = onDragEnd;
|
|
110
|
-
|
|
111
90
|
_this.setContainerBounds(node);
|
|
112
|
-
|
|
113
91
|
_this.move(coords);
|
|
114
92
|
};
|
|
115
|
-
|
|
116
93
|
this.updateProps = function (_ref2) {
|
|
117
94
|
var onDrag = _ref2.onDrag,
|
|
118
|
-
|
|
119
|
-
|
|
95
|
+
onDragEnd = _ref2.onDragEnd,
|
|
96
|
+
onDragStart = _ref2.onDragStart;
|
|
120
97
|
// Check `isDragging` gesture is not in progress. Check if gesture exists before updating the references to the `dragConfig`
|
|
121
|
-
if (!_this.isDragging()) return;
|
|
98
|
+
if (!_this.isDragging()) return;
|
|
122
99
|
|
|
100
|
+
// This will update the `dragConfig` with the new value
|
|
123
101
|
_this.onDrag = onDrag;
|
|
124
102
|
_this.onDragStart = onDragStart;
|
|
125
103
|
_this.onDragEnd = onDragEnd;
|
|
126
104
|
};
|
|
127
|
-
|
|
128
105
|
this.move = function (coords) {
|
|
129
106
|
if (!_this.isDragging()) return;
|
|
130
107
|
var moveTolerance = _this.dragConfig.moveTolerance;
|
|
131
|
-
|
|
132
108
|
if (_this.tracking === Tracking.Untracked) {
|
|
133
109
|
var dx = coords.x - _this.startX;
|
|
134
110
|
var dy = coords.y - _this.startY;
|
|
135
|
-
|
|
136
111
|
if (Math.sqrt(dx * dx + dy * dy) >= moveTolerance) {
|
|
137
112
|
_this.tracking = Tracking.Active;
|
|
138
|
-
|
|
139
113
|
if (_this.onDragStart) {
|
|
140
114
|
_this.onDragStart(_objectSpread({
|
|
141
115
|
type: 'onDragStart'
|
|
@@ -148,45 +122,35 @@ var Drag = /*#__PURE__*/_createClass(function Drag() {
|
|
|
148
122
|
}, coords));
|
|
149
123
|
}
|
|
150
124
|
};
|
|
151
|
-
|
|
152
125
|
this.blur = function () {
|
|
153
126
|
if (!_this.isDragging()) return;
|
|
154
|
-
|
|
155
127
|
if (!_this.dragConfig.global) {
|
|
156
128
|
_this.end();
|
|
157
129
|
}
|
|
158
130
|
};
|
|
159
|
-
|
|
160
131
|
this.end = function () {
|
|
161
132
|
if (!_this.isDragging()) return;
|
|
162
|
-
|
|
163
133
|
if (_this.onDragEnd && _this.tracking !== Tracking.Untracked) {
|
|
164
134
|
_this.onDragEnd({
|
|
165
135
|
type: 'onDragEnd'
|
|
166
136
|
});
|
|
167
137
|
}
|
|
168
|
-
|
|
169
138
|
_this.tracking = Tracking.Untracked;
|
|
170
139
|
_this.dragConfig = null;
|
|
171
140
|
};
|
|
172
|
-
|
|
173
141
|
this.enter = function () {
|
|
174
142
|
if (!_this.isDragging()) return;
|
|
175
|
-
|
|
176
143
|
if (_this.dragConfig.resume && _this.tracking === Tracking.Paused) {
|
|
177
144
|
_this.tracking = Tracking.Active;
|
|
178
145
|
}
|
|
179
146
|
};
|
|
180
|
-
|
|
181
147
|
this.leave = function () {
|
|
182
148
|
if (!_this.isDragging()) return;
|
|
183
|
-
|
|
184
149
|
if (!_this.dragConfig.global && _this.tracking === Tracking.Active) {
|
|
185
150
|
_this.tracking = Tracking.Paused;
|
|
186
151
|
}
|
|
187
152
|
};
|
|
188
153
|
});
|
|
189
|
-
|
|
190
154
|
exports.Drag = Drag;
|
|
191
155
|
var defaultDragConfig = {
|
|
192
156
|
boxSizing: 'border-box',
|
|
@@ -194,13 +158,11 @@ var defaultDragConfig = {
|
|
|
194
158
|
moveTolerance: 16
|
|
195
159
|
};
|
|
196
160
|
exports.defaultDragConfig = defaultDragConfig;
|
|
197
|
-
|
|
198
161
|
var dragConfigPropType = _propTypes["default"].shape({
|
|
199
162
|
boxSizing: _propTypes["default"].string,
|
|
200
163
|
global: _propTypes["default"].bool,
|
|
201
164
|
moveTolerance: _propTypes["default"].number
|
|
202
165
|
});
|
|
203
|
-
|
|
204
166
|
exports.dragConfigPropType = dragConfigPropType;
|
|
205
167
|
var _default = Drag;
|
|
206
168
|
exports["default"] = _default;
|
package/Touchable/Flick.js
CHANGED
|
@@ -4,116 +4,92 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.flickConfigPropType = exports.defaultFlickConfig = exports["default"] = exports.Flick = void 0;
|
|
7
|
-
|
|
8
7
|
var _util = require("@enact/core/util");
|
|
9
|
-
|
|
10
8
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
-
|
|
12
9
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
13
|
-
|
|
14
10
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
15
|
-
|
|
16
11
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
17
|
-
|
|
18
12
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
19
|
-
|
|
20
13
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
21
|
-
|
|
22
14
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
23
|
-
|
|
24
15
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
25
|
-
|
|
26
16
|
var Flick = /*#__PURE__*/function () {
|
|
27
17
|
function Flick() {
|
|
28
18
|
var _this = this;
|
|
29
|
-
|
|
30
19
|
_classCallCheck(this, Flick);
|
|
31
|
-
|
|
32
20
|
this.begin = function (config, _ref, coords) {
|
|
33
21
|
var onFlick = _ref.onFlick;
|
|
34
22
|
_this.flickConfig = _objectSpread({}, config);
|
|
35
|
-
|
|
36
23
|
if (_this.flickConfig.maxDuration !== null) {
|
|
37
24
|
_this.cancelJob.startAfter(_this.flickConfig.maxDuration);
|
|
38
25
|
}
|
|
39
|
-
|
|
40
26
|
_this.tracking = !!onFlick;
|
|
41
27
|
_this.moves.length = 0;
|
|
42
28
|
_this.onFlick = onFlick;
|
|
43
|
-
|
|
44
29
|
_this.move(coords);
|
|
45
30
|
};
|
|
46
|
-
|
|
47
31
|
this.updateProps = function (_ref2) {
|
|
48
32
|
var onFlick = _ref2.onFlick;
|
|
49
33
|
// Check `tracking` gesture is not in progress. Check if gesture exists before updating the references to the `onFlick`
|
|
50
|
-
if (!_this.tracking) return;
|
|
34
|
+
if (!_this.tracking) return;
|
|
51
35
|
|
|
36
|
+
// This will update the `onFlick` with the new value
|
|
52
37
|
_this.onFlick = onFlick;
|
|
53
38
|
};
|
|
54
|
-
|
|
55
39
|
this.move = function (_ref3) {
|
|
56
40
|
var x = _ref3.x,
|
|
57
|
-
|
|
41
|
+
y = _ref3.y;
|
|
58
42
|
if (!_this.tracking) return;
|
|
59
43
|
var maxMoves = _this.flickConfig.maxMoves;
|
|
60
|
-
|
|
61
44
|
_this.moves.push({
|
|
62
45
|
x: x,
|
|
63
46
|
y: y,
|
|
64
47
|
t: window.performance.now()
|
|
65
|
-
});
|
|
66
|
-
|
|
48
|
+
});
|
|
67
49
|
|
|
50
|
+
// track specified # of points
|
|
68
51
|
if (_this.moves.length > maxMoves) {
|
|
69
52
|
_this.moves.shift();
|
|
70
53
|
}
|
|
71
54
|
};
|
|
72
|
-
|
|
73
55
|
this.blur = function () {
|
|
74
56
|
_this.end();
|
|
75
57
|
};
|
|
76
|
-
|
|
77
58
|
this.cancel = function () {
|
|
78
59
|
_this.tracking = false;
|
|
79
60
|
};
|
|
80
|
-
|
|
81
61
|
this.cancelJob = new _util.Job(this.cancel);
|
|
82
|
-
|
|
83
62
|
this.end = function () {
|
|
84
63
|
if (!_this.tracking) return;
|
|
85
64
|
var minVelocity = _this.flickConfig.minVelocity;
|
|
86
|
-
|
|
87
65
|
_this.cancelJob.stop();
|
|
88
|
-
|
|
89
66
|
var moves = _this.moves;
|
|
90
|
-
|
|
91
67
|
if (moves.length > 1) {
|
|
92
68
|
// note: important to use up time to reduce flick
|
|
93
69
|
// velocity based on time between move and up.
|
|
94
70
|
var last = moves[moves.length - 1];
|
|
95
71
|
var t = window.performance.now();
|
|
96
72
|
var x = 0,
|
|
97
|
-
|
|
73
|
+
y = 0;
|
|
98
74
|
|
|
75
|
+
// take the greatest of flick between each tracked move and last move
|
|
99
76
|
for (var i = moves.length - 2, m; m = moves[i]; i--) {
|
|
100
77
|
// this flick (this move - last move) / (this time - last time)
|
|
101
78
|
var dt = t - m.t;
|
|
102
79
|
var vx = (last.x - m.x) / dt;
|
|
103
|
-
var vy = (last.y - m.y) / dt;
|
|
80
|
+
var vy = (last.y - m.y) / dt;
|
|
104
81
|
|
|
82
|
+
// if either axis is a greater flick than previously recorded use this one
|
|
105
83
|
if (Math.abs(vx) > Math.abs(x) || Math.abs(vy) > Math.abs(y)) {
|
|
106
84
|
x = vx;
|
|
107
85
|
y = vy;
|
|
108
86
|
}
|
|
109
87
|
}
|
|
110
|
-
|
|
111
88
|
var v = Math.sqrt(x * x + y * y);
|
|
112
|
-
|
|
113
89
|
if (v > minVelocity) {
|
|
114
|
-
var vertical = Math.abs(y) > Math.abs(x);
|
|
90
|
+
var vertical = Math.abs(y) > Math.abs(x);
|
|
91
|
+
// generate the flick using the start event so it has those coordinates
|
|
115
92
|
// this.sendFlick(ti.startEvent, x, y, v);
|
|
116
|
-
|
|
117
93
|
_this.onFlick({
|
|
118
94
|
type: 'onFlick',
|
|
119
95
|
direction: vertical ? 'vertical' : 'horizontal',
|
|
@@ -123,24 +99,19 @@ var Flick = /*#__PURE__*/function () {
|
|
|
123
99
|
});
|
|
124
100
|
}
|
|
125
101
|
}
|
|
126
|
-
|
|
127
102
|
_this.tracking = false;
|
|
128
103
|
};
|
|
129
|
-
|
|
130
104
|
this.tracking = false;
|
|
131
105
|
this.moves = [];
|
|
132
106
|
}
|
|
133
|
-
|
|
134
107
|
_createClass(Flick, [{
|
|
135
108
|
key: "isTracking",
|
|
136
109
|
value: function isTracking() {
|
|
137
110
|
return this.tracking;
|
|
138
111
|
}
|
|
139
112
|
}]);
|
|
140
|
-
|
|
141
113
|
return Flick;
|
|
142
114
|
}();
|
|
143
|
-
|
|
144
115
|
exports.Flick = Flick;
|
|
145
116
|
var defaultFlickConfig = {
|
|
146
117
|
maxDuration: 250,
|
|
@@ -148,13 +119,11 @@ var defaultFlickConfig = {
|
|
|
148
119
|
minVelocity: 0.1
|
|
149
120
|
};
|
|
150
121
|
exports.defaultFlickConfig = defaultFlickConfig;
|
|
151
|
-
|
|
152
122
|
var flickConfigPropType = _propTypes["default"].shape({
|
|
153
123
|
maxDuration: _propTypes["default"].number,
|
|
154
124
|
maxMoves: _propTypes["default"].number,
|
|
155
125
|
maxVelocity: _propTypes["default"].number
|
|
156
126
|
});
|
|
157
|
-
|
|
158
127
|
exports.flickConfigPropType = flickConfigPropType;
|
|
159
128
|
var _default = Flick;
|
|
160
129
|
exports["default"] = _default;
|
package/Touchable/Hold.js
CHANGED
|
@@ -4,50 +4,37 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.holdConfigPropType = exports.defaultHoldConfig = exports["default"] = exports.Hold = void 0;
|
|
7
|
-
|
|
8
7
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
|
-
|
|
10
8
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
11
|
-
|
|
12
9
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
13
|
-
|
|
14
10
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
15
|
-
|
|
16
11
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
17
|
-
|
|
18
12
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
19
|
-
|
|
20
13
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
21
|
-
|
|
22
14
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
23
|
-
|
|
24
15
|
var Hold = /*#__PURE__*/function () {
|
|
25
16
|
function Hold() {
|
|
26
17
|
var _this = this;
|
|
27
|
-
|
|
28
18
|
_classCallCheck(this, Hold);
|
|
29
|
-
|
|
30
19
|
this.isHolding = function () {
|
|
31
20
|
return _this.holdConfig != null;
|
|
32
21
|
};
|
|
33
|
-
|
|
34
22
|
this.isWithinTolerance = function (_ref) {
|
|
35
23
|
var x = _ref.x,
|
|
36
|
-
|
|
24
|
+
y = _ref.y;
|
|
37
25
|
var moveTolerance = _this.holdConfig.moveTolerance;
|
|
38
26
|
var dx = _this.startX - x;
|
|
39
27
|
var dy = _this.startY - y;
|
|
40
28
|
return Math.sqrt(dx * dx + dy * dy) < moveTolerance;
|
|
41
29
|
};
|
|
42
|
-
|
|
43
30
|
this.begin = function (defaultConfig, _ref2, _ref3) {
|
|
44
31
|
var holdConfig = _ref2.holdConfig,
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
32
|
+
noResume = _ref2.noResume,
|
|
33
|
+
onHoldStart = _ref2.onHoldStart,
|
|
34
|
+
onHoldEnd = _ref2.onHoldEnd,
|
|
35
|
+
onHold = _ref2.onHold;
|
|
49
36
|
var x = _ref3.x,
|
|
50
|
-
|
|
37
|
+
y = _ref3.y;
|
|
51
38
|
if (!onHoldStart && !onHold) return;
|
|
52
39
|
_this.startX = x;
|
|
53
40
|
_this.startY = y;
|
|
@@ -56,47 +43,41 @@ var Hold = /*#__PURE__*/function () {
|
|
|
56
43
|
});
|
|
57
44
|
_this.onHold = onHold;
|
|
58
45
|
_this.onHoldStart = onHoldStart;
|
|
59
|
-
_this.onHoldEnd = onHoldEnd;
|
|
46
|
+
_this.onHoldEnd = onHoldEnd;
|
|
60
47
|
|
|
48
|
+
// copy the events array since it is mutated for each hold
|
|
61
49
|
_this.holdConfig.events = _this.holdConfig.events.slice();
|
|
62
|
-
|
|
63
50
|
_this.holdConfig.events.sort(function (a, b) {
|
|
64
51
|
if (a.time < b.time) return -1;
|
|
65
52
|
if (a.time > b.time) return 1;
|
|
66
53
|
return 0;
|
|
67
54
|
});
|
|
68
|
-
|
|
69
55
|
_this.pulsing = false;
|
|
70
56
|
_this.next = _this.holdConfig.events.shift();
|
|
71
|
-
|
|
72
57
|
if (_this.next) {
|
|
73
58
|
_this.holdStart = window.performance.now();
|
|
74
|
-
|
|
75
59
|
_this.startJob();
|
|
76
60
|
}
|
|
77
61
|
};
|
|
78
|
-
|
|
79
62
|
this.updateProps = function (_ref4) {
|
|
80
63
|
var onHoldStart = _ref4.onHoldStart,
|
|
81
|
-
|
|
82
|
-
|
|
64
|
+
onHoldEnd = _ref4.onHoldEnd,
|
|
65
|
+
onHold = _ref4.onHold;
|
|
83
66
|
// check `isHolding` gesture is not in progress. Check if gesture exists before updating the references to the `holdConfig`
|
|
84
|
-
if (!_this.isHolding()) return;
|
|
67
|
+
if (!_this.isHolding()) return;
|
|
85
68
|
|
|
69
|
+
// Update the original values with new values of the gestures
|
|
86
70
|
_this.onHold = onHold;
|
|
87
71
|
_this.onHoldStart = onHoldStart;
|
|
88
72
|
_this.onHoldEnd = onHoldEnd;
|
|
89
73
|
};
|
|
90
|
-
|
|
91
74
|
this.move = function (coords) {
|
|
92
75
|
if (!_this.isHolding()) return;
|
|
93
76
|
var _this$holdConfig = _this.holdConfig,
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
77
|
+
cancelOnMove = _this$holdConfig.cancelOnMove,
|
|
78
|
+
resume = _this$holdConfig.resume;
|
|
97
79
|
if (cancelOnMove) {
|
|
98
80
|
var shouldEnd = !_this.isWithinTolerance(coords);
|
|
99
|
-
|
|
100
81
|
if (shouldEnd) {
|
|
101
82
|
if (resume) {
|
|
102
83
|
_this.suspend();
|
|
@@ -108,96 +89,75 @@ var Hold = /*#__PURE__*/function () {
|
|
|
108
89
|
}
|
|
109
90
|
}
|
|
110
91
|
};
|
|
111
|
-
|
|
112
92
|
this.blur = function () {
|
|
113
93
|
if (!_this.isHolding()) return;
|
|
114
|
-
|
|
115
94
|
if (!_this.holdConfig.global) {
|
|
116
95
|
_this.end();
|
|
117
96
|
}
|
|
118
97
|
};
|
|
119
|
-
|
|
120
98
|
this.end = function () {
|
|
121
99
|
if (!_this.isHolding()) return;
|
|
122
|
-
|
|
123
100
|
if (_this.pulsing && _this.onHoldEnd) {
|
|
124
101
|
var time = window.performance.now() - _this.holdStart;
|
|
125
|
-
|
|
126
102
|
_this.onHoldEnd({
|
|
127
103
|
type: 'onHoldEnd',
|
|
128
104
|
time: time
|
|
129
105
|
});
|
|
130
106
|
}
|
|
131
|
-
|
|
132
107
|
_this.suspend();
|
|
133
|
-
|
|
134
108
|
_this.pulsing = false;
|
|
135
109
|
_this.holdConfig = null;
|
|
136
110
|
};
|
|
137
|
-
|
|
138
111
|
this.enter = function () {
|
|
139
112
|
if (!_this.isHolding()) return;
|
|
140
113
|
var _this$holdConfig2 = _this.holdConfig,
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
114
|
+
cancelOnMove = _this$holdConfig2.cancelOnMove,
|
|
115
|
+
resume = _this$holdConfig2.resume;
|
|
144
116
|
if (resume && !cancelOnMove) {
|
|
145
117
|
_this.resume();
|
|
146
118
|
}
|
|
147
119
|
};
|
|
148
|
-
|
|
149
120
|
this.leave = function () {
|
|
150
121
|
if (!_this.isHolding()) return;
|
|
151
122
|
var _this$holdConfig3 = _this.holdConfig,
|
|
152
|
-
|
|
153
|
-
|
|
123
|
+
isGlobal = _this$holdConfig3.global,
|
|
124
|
+
resume = _this$holdConfig3.resume;
|
|
154
125
|
if (isGlobal) return;
|
|
155
|
-
|
|
156
126
|
if (resume) {
|
|
157
127
|
_this.suspend();
|
|
158
128
|
} else {
|
|
159
129
|
_this.end();
|
|
160
130
|
}
|
|
161
131
|
};
|
|
162
|
-
|
|
163
132
|
this.suspend = function () {
|
|
164
133
|
clearInterval(_this.holdJob);
|
|
165
134
|
_this.holdJob = null;
|
|
166
135
|
};
|
|
167
|
-
|
|
168
136
|
this.resume = function () {
|
|
169
137
|
if (_this.holdJob !== null) return;
|
|
170
|
-
|
|
171
138
|
_this.handlePulse();
|
|
172
|
-
|
|
173
139
|
_this.startJob();
|
|
174
140
|
};
|
|
175
|
-
|
|
176
141
|
this.handlePulse = function () {
|
|
177
142
|
var holdTime = window.performance.now() - _this.holdStart;
|
|
178
|
-
|
|
179
143
|
var n = _this.next;
|
|
180
|
-
|
|
181
144
|
while (n && n.time <= holdTime) {
|
|
182
145
|
var events = _this.holdConfig.events;
|
|
183
146
|
_this.pulsing = true;
|
|
184
|
-
|
|
185
147
|
if (_this.onHoldStart) {
|
|
186
148
|
_this.onHoldStart(_objectSpread({
|
|
187
149
|
type: 'onHoldStart'
|
|
188
150
|
}, n));
|
|
189
|
-
}
|
|
190
|
-
// additional hold/pulse events
|
|
191
|
-
|
|
151
|
+
}
|
|
192
152
|
|
|
153
|
+
// if the hold is canceled from the onHoldStart handler, we should bail early and prevent
|
|
154
|
+
// additional hold/pulse events
|
|
193
155
|
if (!_this.isHolding()) {
|
|
194
156
|
_this.pulsing = false;
|
|
195
157
|
break;
|
|
196
158
|
}
|
|
197
|
-
|
|
198
159
|
n = _this.next = events && events.shift();
|
|
199
160
|
}
|
|
200
|
-
|
|
201
161
|
if (_this.pulsing) {
|
|
202
162
|
if (_this.onHold) {
|
|
203
163
|
_this.onHold({
|
|
@@ -207,27 +167,22 @@ var Hold = /*#__PURE__*/function () {
|
|
|
207
167
|
}
|
|
208
168
|
}
|
|
209
169
|
};
|
|
210
|
-
|
|
211
170
|
this.holdJob = null;
|
|
212
171
|
this.holdStart = null;
|
|
213
172
|
this.pulsing = false;
|
|
214
173
|
this.next = null;
|
|
215
174
|
}
|
|
216
|
-
|
|
217
175
|
_createClass(Hold, [{
|
|
218
176
|
key: "startJob",
|
|
219
177
|
value: function startJob() {
|
|
220
178
|
var frequency = this.holdConfig.frequency;
|
|
221
|
-
|
|
222
179
|
if (!this.holdJob) {
|
|
223
180
|
this.holdJob = setInterval(this.handlePulse, frequency);
|
|
224
181
|
}
|
|
225
182
|
}
|
|
226
183
|
}]);
|
|
227
|
-
|
|
228
184
|
return Hold;
|
|
229
185
|
}();
|
|
230
|
-
|
|
231
186
|
exports.Hold = Hold;
|
|
232
187
|
var defaultHoldConfig = {
|
|
233
188
|
cancelOnMove: false,
|
|
@@ -240,7 +195,6 @@ var defaultHoldConfig = {
|
|
|
240
195
|
moveTolerance: 16
|
|
241
196
|
};
|
|
242
197
|
exports.defaultHoldConfig = defaultHoldConfig;
|
|
243
|
-
|
|
244
198
|
var holdConfigPropType = _propTypes["default"].shape({
|
|
245
199
|
cancelOnMove: _propTypes["default"].bool,
|
|
246
200
|
events: _propTypes["default"].arrayOf(_propTypes["default"].shape({
|
|
@@ -251,7 +205,6 @@ var holdConfigPropType = _propTypes["default"].shape({
|
|
|
251
205
|
global: _propTypes["default"].bool,
|
|
252
206
|
moveTolerance: _propTypes["default"].number
|
|
253
207
|
});
|
|
254
|
-
|
|
255
208
|
exports.holdConfigPropType = holdConfigPropType;
|
|
256
209
|
var _default = Hold;
|
|
257
210
|
exports["default"] = _default;
|