@enact/ui 4.5.1 → 4.6.0
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.d.ts +1 -1
- package/BodyText/BodyText.js +8 -28
- package/BodyText/tests/BodyText-specs.js +0 -19
- package/Button/Button.d.ts +6 -6
- package/Button/Button.js +33 -63
- package/Button/tests/Button-specs.js +0 -26
- package/CHANGELOG.md +36 -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.d.ts +1 -1
- package/GridListImageItem/GridListImageItem.js +18 -51
- package/Group/Group.js +5 -36
- package/Group/GroupItem.js +16 -33
- package/Group/tests/Group-specs.js +0 -32
- package/Heading/Heading.js +8 -36
- package/Heading/tests/Heading-specs.js +81 -14
- package/Icon/Icon.d.ts +4 -4
- package/Icon/Icon.js +19 -53
- package/Icon/tests/Icon-specs.js +0 -22
- package/IconButton/IconButton.d.ts +4 -4
- package/IconButton/IconButton.js +17 -55
- package/IconButton/tests/IconButton-specs.js +0 -7
- package/Image/Image.js +17 -46
- package/Image/tests/Image-specs.js +0 -14
- package/ImageItem/ImageItem.js +18 -47
- package/ImageItem/tests/ImageItem-specs.js +0 -25
- package/Item/Item.js +9 -33
- package/Item/tests/Item-specs.js +0 -24
- package/LabeledIcon/LabeledIcon.d.ts +2 -2
- package/LabeledIcon/LabeledIcon.js +22 -53
- package/LabeledIcon/tests/LabeledIcon-specs.js +0 -14
- package/Layout/Cell.js +18 -44
- package/Layout/Layout.d.ts +16 -16
- package/Layout/Layout.js +23 -46
- package/Layout/tests/Layout-specs.js +10 -39
- package/Marquee/MarqueeBase.js +31 -64
- package/Marquee/MarqueeController.js +11 -72
- package/Marquee/MarqueeDecorator.js +70 -196
- package/Marquee/index.js +1 -5
- package/Marquee/tests/Marquee-specs.js +295 -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 +1 -5
- package/Placeholder/tests/PlaceholderControllerDecorator-specs.js +25 -0
- package/Placeholder/tests/PlaceholderDecorator-specs.js +28 -0
- package/ProgressBar/ProgressBar.js +14 -45
- 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 +9 -37
- package/Resizable/tests/Resizable-specs.js +34 -0
- package/Routable/Link.js +11 -47
- package/Routable/Routable.d.ts +2 -2
- package/Routable/Routable.js +12 -35
- package/Routable/Route.js +0 -6
- package/Routable/Router.js +15 -58
- 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 +180 -387
- package/Scrollable/ScrollableNative.js +189 -392
- package/Scrollable/Scrollbar.js +30 -102
- package/Scroller/Scroller.js +15 -39
- package/Scroller/ScrollerBasic.js +34 -89
- package/Scroller/UiScrollerBase.js +31 -84
- package/Scroller/tests/Scroller-specs.js +56 -0
- 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.d.ts +2 -2
- package/Slider/Slider.js +29 -67
- package/Slider/tests/Slider-specs.js +94 -7
- package/Slider/utils.js +0 -2
- package/SlotItem/SlotItem.d.ts +1 -1
- package/SlotItem/SlotItem.js +17 -43
- 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.d.ts +1 -1
- package/Spinner/Spinner.js +16 -43
- 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.d.ts +3 -3
- package/ToggleItem/ToggleItem.js +18 -55
- 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 +32 -107
- package/ViewManager/View.js +35 -91
- package/ViewManager/ViewManager.d.ts +1 -1
- package/ViewManager/ViewManager.js +20 -84
- 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 +259 -409
- package/VirtualList/VirtualList.d.ts +4 -4
- package/VirtualList/VirtualList.js +29 -69
- package/VirtualList/VirtualListBase.js +0 -3
- package/VirtualList/VirtualListBasic.js +273 -431
- package/VirtualList/tests/VirtualGridList-native-specs.js +161 -0
- package/VirtualList/tests/VirtualGridList-specs.js +614 -0
- package/VirtualList/tests/VirtualList-native-specs.js +152 -0
- package/VirtualList/tests/VirtualList-specs.js +423 -95
- 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 +6 -20
- 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 +9 -3
- 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/ClickAllow.js
CHANGED
|
@@ -4,15 +4,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports["default"] = exports.ClickAllow = void 0;
|
|
7
|
-
|
|
8
7
|
var _platform = require("@enact/core/platform");
|
|
9
|
-
|
|
10
8
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
11
|
-
|
|
12
9
|
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); } }
|
|
13
|
-
|
|
14
10
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
15
|
-
|
|
16
11
|
// It's possible that emitting `onTap` will cause a DOM change before the mousedown fires resulting
|
|
17
12
|
// in multiple tap/click events for the same user action. To avoid this, we store the last touchend
|
|
18
13
|
// target and timestamp to compare against the next mouse down. If the timestamp is different (e.g
|
|
@@ -23,19 +18,15 @@ var _lastTouchEnd = {
|
|
|
23
18
|
target: null,
|
|
24
19
|
timeStamp: 0
|
|
25
20
|
};
|
|
26
|
-
|
|
27
21
|
var shouldAllowMouseDown = function shouldAllowMouseDown(ev) {
|
|
28
22
|
return ev.timeStamp !== _lastTouchEnd.timeStamp || ev.target === _lastTouchEnd.target || _lastTouchEnd.target === null;
|
|
29
23
|
};
|
|
30
|
-
|
|
31
24
|
var ClickAllow = /*#__PURE__*/function () {
|
|
32
25
|
function ClickAllow() {
|
|
33
26
|
_classCallCheck(this, ClickAllow);
|
|
34
|
-
|
|
35
27
|
this.lastTouchEndTime = 0;
|
|
36
28
|
this.lastMouseUpTime = 0;
|
|
37
29
|
}
|
|
38
|
-
|
|
39
30
|
_createClass(ClickAllow, [{
|
|
40
31
|
key: "setLastTouchEnd",
|
|
41
32
|
value: function setLastTouchEnd(ev) {
|
|
@@ -55,24 +46,24 @@ var ClickAllow = /*#__PURE__*/function () {
|
|
|
55
46
|
}, {
|
|
56
47
|
key: "shouldAllowMouseEvent",
|
|
57
48
|
value: function shouldAllowMouseEvent(ev) {
|
|
58
|
-
var timeStamp = ev.timeStamp;
|
|
49
|
+
var timeStamp = ev.timeStamp;
|
|
59
50
|
|
|
51
|
+
// iOS Safari sends both touch and mouse events (with differing timestamps)
|
|
60
52
|
return !_platform.platform.ios && this.lastTouchEndTime !== timeStamp && shouldAllowMouseDown(ev);
|
|
61
53
|
}
|
|
62
54
|
}, {
|
|
63
55
|
key: "shouldAllowTap",
|
|
64
56
|
value: function shouldAllowTap(ev) {
|
|
65
57
|
var type = ev.type,
|
|
66
|
-
|
|
67
|
-
// last mouseup event which would have fired the click for us
|
|
58
|
+
timeStamp = ev.timeStamp;
|
|
68
59
|
|
|
60
|
+
// Allow the custom tap event for a “click” when it’s actually a click and it’s not from the
|
|
61
|
+
// last mouseup event which would have fired the click for us
|
|
69
62
|
return type === 'click' && this.lastMouseUpTime !== timeStamp;
|
|
70
63
|
}
|
|
71
64
|
}]);
|
|
72
|
-
|
|
73
65
|
return ClickAllow;
|
|
74
66
|
}();
|
|
75
|
-
|
|
76
67
|
exports.ClickAllow = ClickAllow;
|
|
77
68
|
var _default = ClickAllow;
|
|
78
69
|
exports["default"] = _default;
|
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;
|