@enact/ui 4.5.2 → 4.6.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/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 +8 -28
- package/BodyText/tests/BodyText-specs.js +0 -19
- package/Button/Button.js +33 -63
- package/Button/tests/Button-specs.js +0 -26
- package/CHANGELOG.md +45 -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/package.json +3 -0
- 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 +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.js +19 -53
- package/Icon/tests/Icon-specs.js +0 -22
- package/IconButton/IconButton.js +24 -57
- 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.js +22 -53
- package/LabeledIcon/tests/LabeledIcon-specs.js +0 -14
- package/Layout/Cell.js +18 -44
- package/Layout/Layout.js +23 -46
- package/Layout/tests/Layout-specs.js +10 -39
- package/Marquee/MarqueeBase.js +29 -63
- 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 +7 -29
- package/RadioDecorator/RadioDecorator.js +9 -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.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 +37 -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.js +29 -67
- package/Slider/tests/Slider-specs.js +94 -7
- package/Slider/utils.js +0 -2
- package/SlotItem/SlotItem.js +23 -45
- 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 +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.js +24 -57
- 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/Pinch.js +185 -0
- package/Touchable/Touch.js +71 -76
- package/Touchable/Touchable.js +95 -75
- package/Touchable/config.js +27 -24
- package/Touchable/tests/Touchable-specs.js +360 -119
- package/Touchable/tests/useTouch-specs.js +6 -80
- package/Touchable/useTouch.js +57 -65
- 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.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 +265 -409
- 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/AnnounceDecorator/AnnounceDecorator.d.ts +0 -64
- package/BodyText/BodyText.d.ts +0 -66
- package/Button/Button.d.ts +0 -125
- package/Cancelable/Cancelable.d.ts +0 -64
- package/Changeable/Changeable.d.ts +0 -54
- package/ComponentOverride/ComponentOverride.d.ts +0 -52
- package/ForwardRef/ForwardRef.d.ts +0 -22
- package/GridListImageItem/GridListImageItem.d.ts +0 -85
- package/Group/Group.d.ts +0 -107
- package/Heading/Heading.d.ts +0 -90
- package/Icon/Icon.d.ts +0 -88
- package/IconButton/IconButton.d.ts +0 -115
- package/Image/Image.d.ts +0 -113
- package/ImageItem/ImageItem.d.ts +0 -83
- package/Item/Item.d.ts +0 -64
- package/LabeledIcon/LabeledIcon.d.ts +0 -130
- package/Layout/Layout.d.ts +0 -247
- package/Marquee/index.d.ts +0 -258
- package/Measurable/Measurable.d.ts +0 -26
- package/Media/Media.d.ts +0 -99
- package/Placeholder/index.d.ts +0 -53
- package/ProgressBar/ProgressBar.d.ts +0 -92
- package/RadioDecorator/RadioDecorator.d.ts +0 -35
- package/Repeater/Repeater.d.ts +0 -83
- package/Resizable/Resizable.d.ts +0 -31
- package/Routable/Routable.d.ts +0 -148
- package/Scrollable/Scrollable.d.ts +0 -0
- package/Scroller/Scroller.d.ts +0 -276
- package/Skinnable/Skinnable.d.ts +0 -94
- package/Slider/Slider.d.ts +0 -202
- package/SlotItem/SlotItem.d.ts +0 -118
- package/Slottable/Slottable.d.ts +0 -22
- package/Spinner/Spinner.d.ts +0 -95
- package/ToggleIcon/ToggleIcon.d.ts +0 -90
- package/ToggleItem/ToggleItem.d.ts +0 -134
- package/Toggleable/Toggleable.d.ts +0 -103
- package/Touchable/Touchable.d.ts +0 -175
- package/Transition/Transition.d.ts +0 -196
- package/ViewManager/ViewManager.d.ts +0 -191
- package/VirtualList/VirtualList.d.ts +0 -530
- package/index.d.ts +0 -0
- package/internal/IdProvider/IdProvider.d.ts +0 -0
- package/internal/Pure/Pure.d.ts +0 -0
- package/internal/localized-fonts/localized-fonts.d.ts +0 -53
- package/internal/selection/selection.d.ts +0 -0
- package/internal/validators/validators.d.ts +0 -0
- package/resolution/index.d.ts +0 -187
- package/useControlledState/useControlledState.d.ts +0 -0
- package/useScroll/useScroll.d.ts +0 -0
package/Touchable/Touch.js
CHANGED
|
@@ -4,68 +4,59 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports["default"] = exports.Touch = void 0;
|
|
7
|
-
|
|
8
7
|
var _handle = require("@enact/core/handle");
|
|
9
|
-
|
|
10
8
|
var _dispatcher = require("@enact/core/dispatcher");
|
|
11
|
-
|
|
12
9
|
var _complement = _interopRequireDefault(require("ramda/src/complement"));
|
|
13
|
-
|
|
14
10
|
var _platform = _interopRequireDefault(require("@enact/core/platform"));
|
|
15
|
-
|
|
16
11
|
var _config = require("./config");
|
|
17
|
-
|
|
18
12
|
var _state = require("./state");
|
|
19
|
-
|
|
20
13
|
var _ClickAllow = _interopRequireDefault(require("./ClickAllow"));
|
|
21
|
-
|
|
22
14
|
var _Drag = require("./Drag");
|
|
23
|
-
|
|
24
15
|
var _Flick = require("./Flick");
|
|
25
|
-
|
|
26
16
|
var _Hold = require("./Hold");
|
|
27
|
-
|
|
17
|
+
var _Pinch = require("./Pinch");
|
|
28
18
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
29
|
-
|
|
30
19
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
31
|
-
|
|
32
20
|
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); } }
|
|
33
|
-
|
|
34
21
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
35
|
-
|
|
36
22
|
var getEventCoordinates = function getEventCoordinates(ev) {
|
|
37
23
|
var x = ev.clientX,
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
24
|
+
y = ev.clientY,
|
|
25
|
+
type = ev.type;
|
|
41
26
|
if (type.indexOf('touch') === 0) {
|
|
42
|
-
|
|
43
|
-
|
|
27
|
+
if (ev.targetTouches.length >= 2) {
|
|
28
|
+
return Array.from(ev.targetTouches, function (targetTouch) {
|
|
29
|
+
return {
|
|
30
|
+
x: targetTouch.clientX,
|
|
31
|
+
y: targetTouch.clientY
|
|
32
|
+
};
|
|
33
|
+
});
|
|
34
|
+
} else {
|
|
35
|
+
x = ev.targetTouches[0].clientX;
|
|
36
|
+
y = ev.targetTouches[0].clientY;
|
|
37
|
+
}
|
|
44
38
|
}
|
|
45
|
-
|
|
46
39
|
return {
|
|
47
40
|
x: x,
|
|
48
41
|
y: y
|
|
49
42
|
};
|
|
50
|
-
};
|
|
51
|
-
|
|
43
|
+
};
|
|
52
44
|
|
|
45
|
+
// Establish a standard payload for onDown/onUp/onTap events and pass it along to a handler
|
|
53
46
|
var makeTouchableEvent = function makeTouchableEvent(type) {
|
|
54
47
|
return function (ev) {
|
|
55
48
|
var target = ev.target,
|
|
56
|
-
|
|
49
|
+
currentTarget = ev.currentTarget;
|
|
57
50
|
var clientX = ev.clientX,
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
51
|
+
clientY = ev.clientY,
|
|
52
|
+
pageX = ev.pageX,
|
|
53
|
+
pageY = ev.pageY;
|
|
62
54
|
if (ev.changedTouches) {
|
|
63
55
|
clientX = ev.changedTouches[0].clientX;
|
|
64
56
|
clientY = ev.changedTouches[0].clientY;
|
|
65
57
|
pageX = ev.changedTouches[0].pageX;
|
|
66
58
|
pageY = ev.changedTouches[0].pageY;
|
|
67
59
|
}
|
|
68
|
-
|
|
69
60
|
return {
|
|
70
61
|
type: type,
|
|
71
62
|
target: target,
|
|
@@ -77,45 +68,48 @@ var makeTouchableEvent = function makeTouchableEvent(type) {
|
|
|
77
68
|
};
|
|
78
69
|
};
|
|
79
70
|
};
|
|
80
|
-
|
|
81
71
|
var isEnabled = (0, _handle.forProp)('disabled', false);
|
|
82
72
|
var handleDown = (0, _handle.handle)(isEnabled, (0, _handle.adaptEvent)(makeTouchableEvent('onDown'), (0, _handle.forwardWithPrevent)('onDown')), (0, _handle.call)('activate'), (0, _handle.call)('startGesture')).named('handleDown');
|
|
83
73
|
var handleUp = (0, _handle.handle)(isEnabled, (0, _handle.call)('endGesture'), (0, _handle.call)('isTracking'), (0, _handle.adaptEvent)(makeTouchableEvent('onUp'), (0, _handle.forwardWithPrevent)('onUp')), (0, _handle.adaptEvent)(makeTouchableEvent('onTap'), (0, _handle.forward)('onTap')))["finally"]((0, _handle.call)('deactivate')).named('handleUp');
|
|
84
74
|
var handleEnter = (0, _handle.handle)(isEnabled, (0, _handle.forProp)('noResume', false), (0, _handle.call)('enterGesture'), (0, _handle.call)('isPaused'), (0, _handle.call)('activate')).named('handleEnter');
|
|
85
|
-
var handleLeave = (0, _handle.handle)(isEnabled, (0, _handle.call)('leaveGesture'), (0, _handle.oneOf)([(0, _handle.forProp)('noResume', false), (0, _handle.call)('pause')], [_handle.returnsTrue, (0, _handle.call)('deactivate')])).named('handleLeave');
|
|
75
|
+
var handleLeave = (0, _handle.handle)(isEnabled, (0, _handle.call)('leaveGesture'), (0, _handle.oneOf)([(0, _handle.forProp)('noResume', false), (0, _handle.call)('pause')], [_handle.returnsTrue, (0, _handle.call)('deactivate')])).named('handleLeave');
|
|
76
|
+
|
|
77
|
+
// Mouse event handlers
|
|
86
78
|
|
|
87
79
|
var handleMouseDown = (0, _handle.handle)((0, _handle.forward)('onMouseDown'), (0, _handle.call)('shouldAllowMouseEvent'), handleDown);
|
|
88
80
|
var handleMouseEnter = (0, _handle.handle)((0, _handle.forward)('onMouseEnter'), handleEnter);
|
|
89
81
|
var handleMouseMove = (0, _handle.handle)((0, _handle.forward)('onMouseMove'), (0, _handle.call)('moveGesture'));
|
|
90
82
|
var handleMouseLeave = (0, _handle.handle)((0, _handle.forward)('onMouseLeave'), handleLeave);
|
|
91
83
|
var handleMouseUp = (0, _handle.handle)((0, _handle.returnsTrue)((0, _handle.call)('setLastMouseUp')), (0, _handle.forward)('onMouseUp'), handleUp);
|
|
92
|
-
var handleClick = (0, _handle.handle)(isEnabled,
|
|
84
|
+
var handleClick = (0, _handle.handle)(isEnabled,
|
|
85
|
+
// wrapping another handler to always forward onClick but, if onTap should occur, it should
|
|
93
86
|
// occur first to keep in sync with the up handler which emits onTap first
|
|
94
|
-
(0, _handle.handle)((0, _handle.call)('shouldAllowTap'), (0, _handle.call)('activate'), handleUp)["finally"]((0, _handle.forward)('onClick')));
|
|
87
|
+
(0, _handle.handle)((0, _handle.call)('shouldAllowTap'), (0, _handle.call)('activate'), handleUp)["finally"]((0, _handle.forward)('onClick')));
|
|
88
|
+
|
|
89
|
+
// Touch event handlers
|
|
95
90
|
|
|
96
91
|
var handleTouchStart = (0, _handle.handle)((0, _handle.forward)('onTouchStart'), (0, _handle.call)('startTouch'), handleDown);
|
|
97
|
-
var handleTouchMove = (0, _handle.handle)((0, _handle.forward)('onTouchMove'), (0, _handle.call)('isTracking'),
|
|
92
|
+
var handleTouchMove = (0, _handle.handle)((0, _handle.forward)('onTouchMove'), (0, _handle.call)('isTracking'),
|
|
93
|
+
// we don't receive enter/leave events during a touch so we have to simulate them by
|
|
98
94
|
// detecting when the touch leaves the boundary. oneOf returns the value of whichever
|
|
99
95
|
// branch it follows so we append moveHold to either to handle moves that aren't
|
|
100
96
|
// entering or leaving
|
|
101
97
|
(0, _handle.adaptEvent)(makeTouchableEvent('onMove'), (0, _handle.forward)('onMove')), (0, _handle.oneOf)([(0, _handle.call)('hasTouchLeftTarget'), handleLeave], [_handle.returnsTrue, handleEnter])["finally"]((0, _handle.call)('moveGesture')));
|
|
102
|
-
var handleTouchEnd = (0, _handle.handle)((0, _handle.forward)('onTouchEnd'),
|
|
103
|
-
|
|
98
|
+
var handleTouchEnd = (0, _handle.handle)((0, _handle.forward)('onTouchEnd'),
|
|
99
|
+
// block the next mousedown to prevent duplicate touchable events
|
|
100
|
+
(0, _handle.returnsTrue)((0, _handle.call)('setLastTouchEnd')), (0, _handle.call)('isTracking'), (0, _complement["default"])((0, _handle.call)('hasTouchLeftTarget')), (0, _handle.returnsTrue)((0, _handle.call)('endTouch')), handleUp);
|
|
104
101
|
|
|
102
|
+
// Global touchend/mouseup event handler to deactivate the component
|
|
105
103
|
var handleGlobalUp = (0, _handle.handle)((0, _handle.call)('isTracking'), (0, _handle.call)('deactivate'))["finally"]((0, _handle.call)('endGesture'));
|
|
106
104
|
var handleGlobalMove = (0, _handle.handle)((0, _handle.call)('isTracking'), (0, _handle.call)('containsCurrentTarget'), (0, _handle.call)('moveGesture'));
|
|
107
105
|
var handleBlur = (0, _handle.handle)((0, _handle.forward)('onBlur'), (0, _handle.call)('hasFocus'), (0, _handle.call)('blurGesture'));
|
|
108
|
-
|
|
109
106
|
var Touch = /*#__PURE__*/function () {
|
|
110
107
|
function Touch() {
|
|
111
108
|
var _this = this;
|
|
112
|
-
|
|
113
109
|
_classCallCheck(this, Touch);
|
|
114
|
-
|
|
115
110
|
this.getHandlers = function () {
|
|
116
111
|
return _this.handlers;
|
|
117
112
|
};
|
|
118
|
-
|
|
119
113
|
this.context = {};
|
|
120
114
|
this.target = null;
|
|
121
115
|
this.targetHadFocus = false;
|
|
@@ -123,6 +117,7 @@ var Touch = /*#__PURE__*/function () {
|
|
|
123
117
|
this.drag = new _Drag.Drag();
|
|
124
118
|
this.flick = new _Flick.Flick();
|
|
125
119
|
this.hold = new _Hold.Hold();
|
|
120
|
+
this.pinch = new _Pinch.Pinch();
|
|
126
121
|
this.clickAllow = new _ClickAllow["default"]();
|
|
127
122
|
this.handlers = {
|
|
128
123
|
onClick: handleClick.bindAs(this, 'handleClick'),
|
|
@@ -133,7 +128,6 @@ var Touch = /*#__PURE__*/function () {
|
|
|
133
128
|
onMouseLeave: handleMouseLeave.bindAs(this, 'handleMouseLeave'),
|
|
134
129
|
onMouseUp: handleMouseUp.bindAs(this, 'handleMouseUp')
|
|
135
130
|
};
|
|
136
|
-
|
|
137
131
|
if (_platform["default"].touch) {
|
|
138
132
|
Object.assign(this.handlers, {
|
|
139
133
|
onTouchStart: handleTouchStart.bindAs(this, 'handleTouchStart'),
|
|
@@ -141,11 +135,9 @@ var Touch = /*#__PURE__*/function () {
|
|
|
141
135
|
onTouchEnd: handleTouchEnd.bindAs(this, 'handleTouchEnd')
|
|
142
136
|
});
|
|
143
137
|
}
|
|
144
|
-
|
|
145
138
|
handleGlobalUp.bindAs(this, 'handleGlobalUp');
|
|
146
139
|
handleGlobalMove.bindAs(this, 'handleGlobalMove');
|
|
147
140
|
}
|
|
148
|
-
|
|
149
141
|
_createClass(Touch, [{
|
|
150
142
|
key: "setPropsAndContext",
|
|
151
143
|
value: function setPropsAndContext(config, state, setState) {
|
|
@@ -156,11 +148,12 @@ var Touch = /*#__PURE__*/function () {
|
|
|
156
148
|
}
|
|
157
149
|
}, {
|
|
158
150
|
key: "updateGestureConfig",
|
|
159
|
-
value: function updateGestureConfig(dragConfig, flickConfig, holdConfig) {
|
|
151
|
+
value: function updateGestureConfig(dragConfig, flickConfig, holdConfig, pinchConfig) {
|
|
160
152
|
this.config = (0, _config.mergeConfig)({
|
|
161
153
|
drag: dragConfig,
|
|
162
154
|
flick: flickConfig,
|
|
163
|
-
hold: holdConfig
|
|
155
|
+
hold: holdConfig,
|
|
156
|
+
pinch: pinchConfig
|
|
164
157
|
});
|
|
165
158
|
}
|
|
166
159
|
}, {
|
|
@@ -170,7 +163,6 @@ var Touch = /*#__PURE__*/function () {
|
|
|
170
163
|
if (_platform["default"].touch) {
|
|
171
164
|
(0, _dispatcher.on)('touchend', this.handleGlobalUp, document);
|
|
172
165
|
}
|
|
173
|
-
|
|
174
166
|
(0, _dispatcher.on)('mouseup', this.handleGlobalUp, document);
|
|
175
167
|
(0, _dispatcher.on)('mousemove', this.handleGlobalMove, document);
|
|
176
168
|
}
|
|
@@ -180,11 +172,11 @@ var Touch = /*#__PURE__*/function () {
|
|
|
180
172
|
if (_platform["default"].touch) {
|
|
181
173
|
(0, _dispatcher.off)('touchend', this.handleGlobalUp, document);
|
|
182
174
|
}
|
|
183
|
-
|
|
184
175
|
(0, _dispatcher.off)('mouseup', this.handleGlobalUp, document);
|
|
185
176
|
(0, _dispatcher.off)('mousemove', this.handleGlobalMove, document);
|
|
186
|
-
}
|
|
177
|
+
}
|
|
187
178
|
|
|
179
|
+
// State Management
|
|
188
180
|
}, {
|
|
189
181
|
key: "setTarget",
|
|
190
182
|
value: function setTarget(target) {
|
|
@@ -199,22 +191,18 @@ var Touch = /*#__PURE__*/function () {
|
|
|
199
191
|
key: "activate",
|
|
200
192
|
value: function activate(ev) {
|
|
201
193
|
this.setTarget(ev.currentTarget);
|
|
202
|
-
|
|
203
194
|
if (this.props.getActive) {
|
|
204
195
|
this.context.setState(_state.States.Active);
|
|
205
196
|
}
|
|
206
|
-
|
|
207
197
|
return true;
|
|
208
198
|
}
|
|
209
199
|
}, {
|
|
210
200
|
key: "deactivate",
|
|
211
201
|
value: function deactivate() {
|
|
212
202
|
this.clearTarget();
|
|
213
|
-
|
|
214
203
|
if (this.props.getActive) {
|
|
215
204
|
this.context.setState(_state.States.Inactive);
|
|
216
205
|
}
|
|
217
|
-
|
|
218
206
|
return true;
|
|
219
207
|
}
|
|
220
208
|
}, {
|
|
@@ -223,7 +211,6 @@ var Touch = /*#__PURE__*/function () {
|
|
|
223
211
|
if (this.props.getActive && this.context.state === _state.States.Active) {
|
|
224
212
|
this.context.setState(_state.States.Paused);
|
|
225
213
|
}
|
|
226
|
-
|
|
227
214
|
return true;
|
|
228
215
|
}
|
|
229
216
|
}, {
|
|
@@ -235,24 +222,24 @@ var Touch = /*#__PURE__*/function () {
|
|
|
235
222
|
}, {
|
|
236
223
|
key: "updateProps",
|
|
237
224
|
value: function updateProps(props) {
|
|
238
|
-
// Update the props onHoldStart, onHold, and onHoldEnd on any gesture (hold, flick, drag).
|
|
225
|
+
// Update the props onHoldStart, onHold, and onHoldEnd on any gesture (pinch, hold, flick, drag).
|
|
226
|
+
this.pinch.updateProps(props);
|
|
239
227
|
this.hold.updateProps(props);
|
|
240
228
|
this.flick.updateProps(props);
|
|
241
229
|
this.drag.updateProps(props);
|
|
242
|
-
}
|
|
230
|
+
}
|
|
243
231
|
|
|
232
|
+
// Gesture Support
|
|
244
233
|
}, {
|
|
245
234
|
key: "startTouch",
|
|
246
235
|
value: function startTouch(_ref) {
|
|
247
236
|
var target = _ref.target,
|
|
248
|
-
|
|
249
|
-
|
|
237
|
+
currentTarget = _ref.currentTarget;
|
|
250
238
|
if (currentTarget.contains(target)) {
|
|
251
239
|
(0, _dispatcher.on)('contextmenu', _handle.preventDefault);
|
|
252
240
|
this.targetBounds = currentTarget.getBoundingClientRect();
|
|
253
241
|
return true;
|
|
254
242
|
}
|
|
255
|
-
|
|
256
243
|
return false;
|
|
257
244
|
}
|
|
258
245
|
}, {
|
|
@@ -266,12 +253,17 @@ var Touch = /*#__PURE__*/function () {
|
|
|
266
253
|
value: function startGesture(ev, props) {
|
|
267
254
|
var coords = getEventCoordinates(ev);
|
|
268
255
|
var _this$config = this.config,
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
256
|
+
pinch = _this$config.pinch,
|
|
257
|
+
hold = _this$config.hold,
|
|
258
|
+
flick = _this$config.flick,
|
|
259
|
+
drag = _this$config.drag;
|
|
260
|
+
if (Array.isArray(coords)) {
|
|
261
|
+
this.pinch.begin(pinch, props, coords, this.target);
|
|
262
|
+
} else {
|
|
263
|
+
this.hold.begin(hold, props, coords);
|
|
264
|
+
this.flick.begin(flick, props, coords);
|
|
265
|
+
this.drag.begin(drag, props, coords, this.target);
|
|
266
|
+
}
|
|
275
267
|
this.targetHadFocus = this.target === document.activeElement;
|
|
276
268
|
return true;
|
|
277
269
|
}
|
|
@@ -279,9 +271,13 @@ var Touch = /*#__PURE__*/function () {
|
|
|
279
271
|
key: "moveGesture",
|
|
280
272
|
value: function moveGesture(ev) {
|
|
281
273
|
var coords = getEventCoordinates(ev);
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
274
|
+
if (Array.isArray(coords)) {
|
|
275
|
+
this.pinch.move(coords);
|
|
276
|
+
} else {
|
|
277
|
+
this.hold.move(coords);
|
|
278
|
+
this.flick.move(coords);
|
|
279
|
+
this.drag.move(coords);
|
|
280
|
+
}
|
|
285
281
|
return true;
|
|
286
282
|
}
|
|
287
283
|
}, {
|
|
@@ -311,12 +307,14 @@ var Touch = /*#__PURE__*/function () {
|
|
|
311
307
|
key: "endGesture",
|
|
312
308
|
value: function endGesture() {
|
|
313
309
|
this.targetHadFocus = false;
|
|
310
|
+
this.pinch.end();
|
|
314
311
|
this.hold.end();
|
|
315
312
|
this.flick.end();
|
|
316
313
|
this.drag.end();
|
|
317
314
|
return true;
|
|
318
|
-
}
|
|
315
|
+
}
|
|
319
316
|
|
|
317
|
+
// Event handler utilities
|
|
320
318
|
}, {
|
|
321
319
|
key: "isTracking",
|
|
322
320
|
value: function isTracking() {
|
|
@@ -337,15 +335,14 @@ var Touch = /*#__PURE__*/function () {
|
|
|
337
335
|
key: "hasTouchLeftTarget",
|
|
338
336
|
value: function hasTouchLeftTarget(ev) {
|
|
339
337
|
var _this2 = this;
|
|
340
|
-
|
|
341
338
|
return Array.from(ev.changedTouches).reduce(function (hasLeft, _ref2) {
|
|
342
339
|
var pageX = _ref2.pageX,
|
|
343
|
-
|
|
340
|
+
pageY = _ref2.pageY;
|
|
344
341
|
var _this2$targetBounds = _this2.targetBounds,
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
342
|
+
left = _this2$targetBounds.left,
|
|
343
|
+
right = _this2$targetBounds.right,
|
|
344
|
+
top = _this2$targetBounds.top,
|
|
345
|
+
bottom = _this2$targetBounds.bottom;
|
|
349
346
|
return hasLeft && left > pageX || right < pageX || top > pageY || bottom < pageY;
|
|
350
347
|
}, true);
|
|
351
348
|
}
|
|
@@ -376,10 +373,8 @@ var Touch = /*#__PURE__*/function () {
|
|
|
376
373
|
this.clickAllow.setLastTouchEnd(ev);
|
|
377
374
|
}
|
|
378
375
|
}]);
|
|
379
|
-
|
|
380
376
|
return Touch;
|
|
381
377
|
}();
|
|
382
|
-
|
|
383
378
|
exports.Touch = Touch;
|
|
384
379
|
var _default = Touch;
|
|
385
380
|
exports["default"] = _default;
|