@enact/ui 5.6.0 → 5.7.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 +8 -8
- package/AnnounceDecorator/AnnounceDecorator.js +5 -5
- package/BodyText/BodyText.js +5 -5
- package/BodyText/tests/BodyText-specs.js +2 -1
- package/Button/Button.js +5 -5
- package/CHANGELOG.md +18 -0
- package/Cancelable/Cancelable.js +9 -9
- package/Cancelable/tests/Cancelable-specs.js +5 -5
- package/Card/Card.js +5 -5
- package/Card/tests/Card-specs.js +2 -1
- package/Changeable/Changeable.js +9 -9
- package/ComponentOverride/ComponentOverride.js +15 -11
- package/FloatingLayer/FloatingLayer.js +10 -10
- package/FloatingLayer/FloatingLayerContainer.js +3 -3
- package/FloatingLayer/FloatingLayerDecorator.js +5 -5
- package/FloatingLayer/Scrim.js +9 -9
- package/FloatingLayer/tests/useFloatingLayerDecorator-specs.js +4 -4
- package/FloatingLayer/useFloatingLayer.js +3 -4
- package/ForwardRef/ForwardRef.js +5 -5
- package/Group/Group.js +5 -5
- package/Group/GroupItem.js +5 -5
- package/Group/tests/Group-specs.js +2 -1
- package/Heading/Heading.js +5 -5
- package/Icon/Icon.js +5 -5
- package/Icon/tests/Icon-specs.js +2 -1
- package/Image/Image.js +5 -5
- package/Image/tests/Image-specs.js +2 -1
- package/ImageItem/ImageItem.js +5 -5
- package/ImageItem/tests/ImageItem-specs.js +6 -5
- package/Item/Item.js +5 -5
- package/LabeledIcon/LabeledIcon.js +5 -5
- package/Layout/Cell.js +5 -5
- package/Layout/Layout.js +5 -5
- package/Layout/tests/Layout-specs.js +9 -9
- package/Marquee/Marquee.module.css +44 -0
- package/Marquee/MarqueeBase.js +134 -21
- package/Marquee/MarqueeController.js +4 -4
- package/Marquee/MarqueeDecorator.js +219 -27
- package/Marquee/index.d.ts +60 -12
- package/Marquee/tests/Marquee-specs.js +3 -3
- package/Marquee/tests/Marquee-vertical-specs.js +1358 -0
- package/Marquee/useMarqueeController.js +4 -4
- package/Marquee/utils.js +22 -0
- package/Marquee/verticalMeasure.js +118 -0
- package/Measurable/Measurable.js +8 -9
- package/Measurable/tests/Measurable-specs.js +7 -6
- package/Media/Media.js +10 -10
- package/Placeholder/PlaceholderControllerDecorator.js +9 -9
- package/Placeholder/PlaceholderDecorator.js +9 -9
- package/Placeholder/tests/PlaceholderControllerDecorator-specs.js +4 -4
- package/ProgressBar/ProgressBar.js +5 -5
- package/Repeater/Repeater.js +5 -5
- package/Repeater/tests/Repeater-specs.js +6 -5
- package/Resizable/Resizable.js +4 -4
- package/Resizable/tests/Resizable-specs.js +2 -1
- package/Resizable/tests/useResize-specs.js +4 -4
- package/Resizable/useResize.js +3 -3
- package/Routable/Link.js +9 -9
- package/Routable/Routable.js +5 -5
- package/Routable/Router.js +9 -9
- package/Routable/tests/Routable-specs.js +7 -8
- package/Routable/tests/Router-specs.js +1 -1
- package/Scroller/Scroller.js +4 -4
- package/Scroller/ScrollerBasic.js +10 -10
- package/Skinnable/Skinnable.js +5 -5
- package/Skinnable/tests/Skinnable-specs.js +4 -4
- package/Skinnable/tests/useSkins-specs.js +4 -4
- package/Slider/Knob.js +5 -5
- package/Slider/PositionDecorator.js +8 -8
- package/Slider/Slider.js +5 -5
- package/Slottable/Slottable.js +4 -4
- package/Slottable/useSlots.js +5 -5
- package/Spinner/Spinner.js +5 -5
- package/ToggleIcon/ToggleIcon.js +5 -5
- package/Toggleable/Toggle.js +5 -5
- package/Toggleable/Toggleable.js +9 -9
- package/Toggleable/useToggle.js +5 -5
- package/Touchable/ClickAllow.js +3 -3
- package/Touchable/Drag.js +6 -6
- package/Touchable/Flick.js +5 -5
- package/Touchable/Hold.js +5 -5
- package/Touchable/Pinch.js +6 -6
- package/Touchable/Touch.js +3 -3
- package/Touchable/Touchable.js +5 -5
- package/Touchable/config.js +4 -4
- package/Touchable/tests/Touchable-specs.js +1 -1
- package/Touchable/tests/useTouch-specs.js +5 -5
- package/Touchable/useTouch.js +7 -8
- package/Transition/Transition.js +14 -13
- package/Transition/tests/Transition-specs.js +9 -9
- package/ViewManager/Arranger.js +4 -4
- package/ViewManager/TransitionGroup.js +7 -7
- package/ViewManager/View.js +9 -9
- package/ViewManager/ViewManager.js +11 -10
- package/ViewManager/tests/ViewManager-specs.js +6 -6
- package/VirtualList/VirtualList.js +4 -4
- package/VirtualList/VirtualListBasic.js +67 -47
- package/VirtualList/tests/VirtualGridList-native-specs.js +5 -5
- package/VirtualList/tests/VirtualGridList-specs.js +16 -15
- package/VirtualList/tests/VirtualList-native-specs.js +164 -16
- package/VirtualList/tests/VirtualList-specs.js +16 -15
- package/internal/IdProvider/IdProvider.js +4 -4
- package/internal/IdProvider/Provider.js +3 -3
- package/internal/IdProvider/tests/IdProvider-specs.js +4 -4
- package/internal/IdProvider/tests/useId-specs.js +16 -8
- package/internal/Pure/Pure.js +9 -9
- package/internal/Pure/tests/Pure-specs.js +8 -8
- package/internal/localized-fonts/localized-fonts.js +3 -4
- package/package.json +6 -6
- package/resolution/ResolutionDecorator.js +71 -87
- package/resolution/index.js +2 -1
- package/resolution/tests/resolution-specs.js +7 -8
- package/useControlledState/tests/useControlledState-specs.js +3 -4
- package/useControlledState/useControlledState.js +3 -4
- package/useScroll/ScrollAnimator.js +3 -3
- package/useScroll/Scrollbar.js +5 -5
- package/useScroll/ScrollbarTrack.js +5 -5
- package/useScroll/scrollMotion.js +126 -0
- package/useScroll/tests/scrollMotion-specs.js +215 -0
- package/useScroll/tests/useScroll-specs.js +430 -9
- package/useScroll/useScroll.js +156 -92
package/useScroll/useScroll.js
CHANGED
|
@@ -19,12 +19,13 @@ var _Resizable = require("../Resizable");
|
|
|
19
19
|
var _resolution = _interopRequireDefault(require("../resolution"));
|
|
20
20
|
var _Touchable = _interopRequireDefault(require("../Touchable"));
|
|
21
21
|
var _ScrollAnimator = _interopRequireDefault(require("./ScrollAnimator"));
|
|
22
|
+
var _scrollMotion = require("./scrollMotion");
|
|
22
23
|
var _utilDOM = _interopRequireDefault(require("./utilDOM"));
|
|
23
24
|
var _utilEvent = _interopRequireDefault(require("./utilEvent"));
|
|
24
25
|
var _useScrollModule = _interopRequireDefault(require("./useScroll.module.css"));
|
|
25
26
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
26
27
|
var _excluded = ["ref"],
|
|
27
|
-
_excluded2 = ["childProps", "children", "className", "clientSize", "assignProperties", "dataSize", "direction", "horizontalScrollbar", "horizontalScrollbarHandle", "itemRenderer", "noScrollByDrag", "noScrollByWheel", "overhang", "overscrollEffectOn", "pageScroll", "role", "rtl", "scrollContainerRef", "scrollContentHandle", "scrollContentRef", "scrollMode", "setScrollContainerHandle", "snapToCenter", "spacing", "spotlightContainerDisabled", "verticalScrollbar", "verticalScrollbarHandle", "wrap"];
|
|
28
|
+
_excluded2 = ["childProps", "children", "className", "clientSize", "assignProperties", "dataSize", "direction", "getScrollMotion", "horizontalScrollbar", "horizontalScrollbarHandle", "itemRenderer", "noScrollByDrag", "noScrollByWheel", "overhang", "overscrollEffectOn", "pageScroll", "role", "rtl", "scrollContainerRef", "scrollContentHandle", "scrollContentRef", "scrollMode", "setScrollContainerHandle", "snapToCenter", "spacing", "spotlightContainerDisabled", "verticalScrollbar", "verticalScrollbarHandle", "wrap"];
|
|
28
29
|
/* global ResizeObserver */
|
|
29
30
|
/**
|
|
30
31
|
* Unstyled scrollable hook and behaviors to be customized by a theme or application.
|
|
@@ -38,18 +39,17 @@ var _excluded = ["ref"],
|
|
|
38
39
|
*/
|
|
39
40
|
// scrollMode 'native'
|
|
40
41
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
41
|
-
function _slicedToArray(
|
|
42
|
+
function _slicedToArray(e, i) { return _iterableToArrayLimit(e, i) || _unsupportedIterableToArray(e, i) || _nonIterableRest(); }
|
|
42
43
|
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
43
|
-
function _unsupportedIterableToArray(
|
|
44
|
+
function _unsupportedIterableToArray(t, e) { if (t) { if ("string" == typeof t) return _arrayLikeToArray(t, e); var o = {}.toString.call(t).slice(8, -1); return "Object" === o && t.constructor && (o = t.constructor.name), "Map" === o || "Set" === o ? Array.from(t) : "Arguments" === o || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(o) ? _arrayLikeToArray(t, e) : void 0; } }
|
|
44
45
|
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
45
|
-
function _iterableToArrayLimit(r,
|
|
46
|
-
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
46
|
+
function _iterableToArrayLimit(r, t) { var e = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (Array.isArray(r) && (null == e || e === ("undefined" != typeof Symbol && [][Symbol.iterator]) || e === []["@@iterator"])) return r; if (null != e) { var l, n, i, a, u = [], o = !0, f = !1; try { if (i = (e = e.call(r)).next, 0 === t) { if (Object(e) !== e) return; o = !1; } else for (; !(o = (l = i.call(e)).done) && (u.push(l.value), u.length !== t); o = !0); } catch (r) { f = !0, n = r; } finally { try { if (!o && null != e["return"] && (a = e["return"](), Object(a) !== a)) return; } finally { if (f) throw n; } } return u; } }
|
|
47
47
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
48
|
-
function _objectSpread(
|
|
49
|
-
function _defineProperty(
|
|
50
|
-
function _toPropertyKey(
|
|
51
|
-
function _toPrimitive(t,
|
|
52
|
-
function _objectWithoutProperties(
|
|
48
|
+
function _objectSpread(r) { for (var t = 1; t < arguments.length; t++) { var o = null != arguments[t] ? arguments[t] : {}; t % 2 ? ownKeys(Object(o), !0).forEach(function (t) { _defineProperty(r, t, o[t]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(r, Object.getOwnPropertyDescriptors(o)) : ownKeys(Object(o)).forEach(function (e) { Object.defineProperty(r, e, Object.getOwnPropertyDescriptor(o, e)); }); } return r; }
|
|
49
|
+
function _defineProperty(r, t, o) { return (t = _toPropertyKey(t)) in r ? Object.defineProperty(r, t, { value: o, enumerable: !0, configurable: !0, writable: !0 }) : r[t] = o, r; }
|
|
50
|
+
function _toPropertyKey(r) { var o = _toPrimitive(r, "string"); return "symbol" == typeof o ? o : o + ""; }
|
|
51
|
+
function _toPrimitive(t, e) { if ("object" != typeof t || !t) return t; var r; if ("undefined" != typeof Symbol && void 0 !== (r = t[Symbol.toPrimitive])) { var i = r.call(t, e || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === e ? String : Number)(t); }
|
|
52
|
+
function _objectWithoutProperties(t, r) { if (null == t) return {}; var o, n, i = _objectWithoutPropertiesLoose(t, r); if (Object.getOwnPropertySymbols) { var l = Object.getOwnPropertySymbols(t); for (n = 0; n < l.length; n++) o = l[n], -1 === r.indexOf(o) && {}.propertyIsEnumerable.call(t, o) && (i[o] = t[o]); } return i; }
|
|
53
53
|
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
|
|
54
54
|
var constants = exports.constants = {
|
|
55
55
|
animationDuration: 1000,
|
|
@@ -146,6 +146,7 @@ var useScrollBase = exports.useScrollBase = function useScrollBase(props) {
|
|
|
146
146
|
assignProperties = props.assignProperties,
|
|
147
147
|
dataSize = props.dataSize,
|
|
148
148
|
direction = props.direction,
|
|
149
|
+
getScrollMotion = props.getScrollMotion,
|
|
149
150
|
horizontalScrollbar = props.horizontalScrollbar,
|
|
150
151
|
horizontalScrollbarHandle = props.horizontalScrollbarHandle,
|
|
151
152
|
itemRenderer = props.itemRenderer,
|
|
@@ -177,6 +178,7 @@ var useScrollBase = exports.useScrollBase = function useScrollBase(props) {
|
|
|
177
178
|
delete rest.applyOverscrollEffect;
|
|
178
179
|
delete rest.cbScrollTo;
|
|
179
180
|
delete rest.clearOverscrollEffect;
|
|
181
|
+
delete rest.getScrollMotion;
|
|
180
182
|
delete rest.handleResizeWindow;
|
|
181
183
|
delete rest.itemSize;
|
|
182
184
|
delete rest.itemSizes;
|
|
@@ -425,12 +427,12 @@ var useScrollBase = exports.useScrollBase = function useScrollBase(props) {
|
|
|
425
427
|
|
|
426
428
|
// componentWillUnmount
|
|
427
429
|
return function () {
|
|
428
|
-
var
|
|
429
|
-
|
|
430
|
-
resizeRegistry =
|
|
431
|
-
scrolling =
|
|
432
|
-
scrollStopJob =
|
|
433
|
-
|
|
430
|
+
var state = mutableRef.current; // eslint-disable-line react-hooks/exhaustive-deps
|
|
431
|
+
var animator = state.animator,
|
|
432
|
+
resizeRegistry = state.resizeRegistry,
|
|
433
|
+
scrolling = state.scrolling,
|
|
434
|
+
scrollStopJob = state.scrollStopJob;
|
|
435
|
+
(0, _scrollMotion.cancelScrollMotion)(state);
|
|
434
436
|
resizeRegistry.parent = null;
|
|
435
437
|
|
|
436
438
|
// Before call cancelAnimationFrame, you must send scrollStop Event.
|
|
@@ -550,10 +552,10 @@ var useScrollBase = exports.useScrollBase = function useScrollBase(props) {
|
|
|
550
552
|
|
|
551
553
|
(0, _react.useLayoutEffect)(function () {
|
|
552
554
|
var hasDataSizeChanged = scrollContentHandle.current.hasDataSizeChanged,
|
|
553
|
-
_mutableRef$
|
|
554
|
-
prevState = _mutableRef$
|
|
555
|
-
resizeRegistry = _mutableRef$
|
|
556
|
-
scrollToInfo = _mutableRef$
|
|
555
|
+
_mutableRef$current = mutableRef.current,
|
|
556
|
+
prevState = _mutableRef$current.prevState,
|
|
557
|
+
resizeRegistry = _mutableRef$current.resizeRegistry,
|
|
558
|
+
scrollToInfo = _mutableRef$current.scrollToInfo;
|
|
557
559
|
|
|
558
560
|
// Need to sync calculated client size if it is different from the real size
|
|
559
561
|
if (scrollContentHandle.current.syncClientSize) {
|
|
@@ -929,7 +931,7 @@ var useScrollBase = exports.useScrollBase = function useScrollBase(props) {
|
|
|
929
931
|
*/
|
|
930
932
|
function onScrollEnd(ev) {
|
|
931
933
|
var _scrollContentHandle$;
|
|
932
|
-
if (!mutableRef.current.scrolling || mutableRef.current.keyPressed || (_scrollContentHandle$ = scrollContentHandle.current) !== null && _scrollContentHandle$ !== void 0 && _scrollContentHandle$.scrolling) {
|
|
934
|
+
if (!mutableRef.current.scrolling || mutableRef.current.keyPressed || mutableRef.current.motionAnimating || (_scrollContentHandle$ = scrollContentHandle.current) !== null && _scrollContentHandle$ !== void 0 && _scrollContentHandle$.scrolling) {
|
|
933
935
|
return;
|
|
934
936
|
}
|
|
935
937
|
updateScrollPosition(ev);
|
|
@@ -1020,7 +1022,7 @@ var useScrollBase = exports.useScrollBase = function useScrollBase(props) {
|
|
|
1020
1022
|
isVertical = orientation === 'vertical',
|
|
1021
1023
|
baseSize = isVertical ? bounds.clientHeight : bounds.clientWidth,
|
|
1022
1024
|
maxPos = bounds[isVertical ? 'maxTop' : 'maxLeft'];
|
|
1023
|
-
var overDistance
|
|
1025
|
+
var overDistance;
|
|
1024
1026
|
if (position < 0) {
|
|
1025
1027
|
overDistance = -position;
|
|
1026
1028
|
} else if (position > maxPos) {
|
|
@@ -1220,85 +1222,143 @@ var useScrollBase = exports.useScrollBase = function useScrollBase(props) {
|
|
|
1220
1222
|
}
|
|
1221
1223
|
// scrollMode 'translate' ]]
|
|
1222
1224
|
|
|
1223
|
-
function start(
|
|
1224
|
-
var
|
|
1225
|
+
function start() {
|
|
1226
|
+
var _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
1227
|
+
targetX = _ref2.targetX,
|
|
1225
1228
|
targetY = _ref2.targetY,
|
|
1226
1229
|
_ref2$animate = _ref2.animate,
|
|
1227
1230
|
animate = _ref2$animate === void 0 ? true : _ref2$animate,
|
|
1228
|
-
|
|
1229
|
-
duration = _ref2$duration === void 0 ? animationDuration : _ref2$duration,
|
|
1231
|
+
requestedDuration = _ref2.duration,
|
|
1230
1232
|
_ref2$overscrollEffec = _ref2.overscrollEffect,
|
|
1231
1233
|
overscrollEffect = _ref2$overscrollEffec === void 0 ? false : _ref2$overscrollEffec;
|
|
1232
|
-
var
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
var
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1234
|
+
var motion = animate ? (0, _scrollMotion.resolveScrollMotion)({
|
|
1235
|
+
duration: requestedDuration,
|
|
1236
|
+
keyPressed: mutableRef.current.keyPressed,
|
|
1237
|
+
repeat: mutableRef.current.repeat,
|
|
1238
|
+
getScrollMotion: getScrollMotion
|
|
1239
|
+
}) : null;
|
|
1240
|
+
var begin = function begin(skipSameTarget) {
|
|
1241
|
+
// An explicit duration (a flick) or a motion token is used as-is. The default
|
|
1242
|
+
// duration is still capped by the distance of the scroll.
|
|
1243
|
+
var duration = animationDuration;
|
|
1244
|
+
if (requestedDuration != null) duration = requestedDuration;else if (motion) duration = motion.duration;
|
|
1245
|
+
var _mutableRef$current2 = mutableRef.current,
|
|
1246
|
+
scrollLeft = _mutableRef$current2.scrollLeft,
|
|
1247
|
+
scrollTop = _mutableRef$current2.scrollTop,
|
|
1248
|
+
bounds = getScrollBounds(),
|
|
1249
|
+
maxLeft = bounds.maxLeft,
|
|
1250
|
+
maxTop = bounds.maxTop,
|
|
1251
|
+
fixedDuration = requestedDuration != null || !!(motion && motion.duration > 0),
|
|
1252
|
+
shouldAnimate = animate && !(motion && motion.duration <= 0);
|
|
1253
|
+
|
|
1254
|
+
// A motion scroll aims inside the range. A target past the end would reach the edge
|
|
1255
|
+
// early and then sit still for the rest of the duration. The requested target is kept
|
|
1256
|
+
// for the overscroll check, so a page key at the edge still bounces.
|
|
1257
|
+
var scrollTargetX = targetX;
|
|
1258
|
+
var scrollTargetY = targetY;
|
|
1259
|
+
if (motion) {
|
|
1260
|
+
scrollTargetX = (0, _clamp["default"])(0, maxLeft, targetX);
|
|
1261
|
+
scrollTargetY = (0, _clamp["default"])(0, maxTop, targetY);
|
|
1259
1262
|
}
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
if (Math.abs(maxLeft - targetX) < epsilon) {
|
|
1263
|
-
targetX = maxLeft;
|
|
1264
|
-
}
|
|
1265
|
-
if (Math.abs(maxTop - targetY) < epsilon) {
|
|
1266
|
-
targetY = maxTop;
|
|
1267
|
-
}
|
|
1268
|
-
if (mutableRef.current.overscrollEnabled && overscrollEffect) {
|
|
1269
|
-
if (scrollLeft !== targetX && canScrollHorizontally(bounds)) {
|
|
1270
|
-
checkAndApplyOverscrollEffectOnStart('horizontal', getEdgeFromPosition(targetX, maxLeft), targetX);
|
|
1263
|
+
if (Math.abs(maxLeft - scrollTargetX) < epsilon) {
|
|
1264
|
+
scrollTargetX = maxLeft;
|
|
1271
1265
|
}
|
|
1272
|
-
if (
|
|
1273
|
-
|
|
1266
|
+
if (Math.abs(maxTop - scrollTargetY) < epsilon) {
|
|
1267
|
+
scrollTargetY = maxTop;
|
|
1274
1268
|
}
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1269
|
+
var updatedAnimationInfo = scrollMode === 'translate' ? {
|
|
1270
|
+
sourceX: scrollLeft,
|
|
1271
|
+
sourceY: scrollTop,
|
|
1272
|
+
targetX: scrollTargetX,
|
|
1273
|
+
targetY: scrollTargetY,
|
|
1274
|
+
duration: duration,
|
|
1275
|
+
fixedDuration: fixedDuration,
|
|
1276
|
+
timingFunction: motion && motion.timingFunction
|
|
1277
|
+
} : {
|
|
1278
|
+
targetX: scrollTargetX,
|
|
1279
|
+
targetY: scrollTargetY
|
|
1280
|
+
};
|
|
1281
|
+
|
|
1282
|
+
// Ignore only a repeat of the scroll already in progress. A new target replaces it,
|
|
1283
|
+
// so a 5-way or page key during the motion is not dropped.
|
|
1284
|
+
var previousAnimationInfo = mutableRef.current.animationInfo;
|
|
1285
|
+
var animating = scrollMode === 'translate' && mutableRef.current.animator.isAnimating() || scrollMode === 'native' && mutableRef.current.scrolling;
|
|
1286
|
+
if (!skipSameTarget && animating && previousAnimationInfo && previousAnimationInfo.targetX === scrollTargetX && previousAnimationInfo.targetY === scrollTargetY) {
|
|
1287
|
+
return;
|
|
1280
1288
|
}
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1289
|
+
mutableRef.current.animationInfo = updatedAnimationInfo;
|
|
1290
|
+
(0, _scrollMotion.cancelScrollMotion)(mutableRef.current);
|
|
1291
|
+
if (scrollMode === 'translate') {
|
|
1292
|
+
mutableRef.current.animator.stop();
|
|
1293
|
+
if (!mutableRef.current.scrolling) {
|
|
1294
|
+
mutableRef.current.scrolling = true;
|
|
1295
|
+
forwardScrollEvent('onScrollStart');
|
|
1296
|
+
}
|
|
1297
|
+
mutableRef.current.scrollStopJob.stop();
|
|
1286
1298
|
}
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
scrollContentHandle.current.scrollToPosition(roundedTargetX, roundedTargetY, 'instant');
|
|
1299
|
+
var overscrollX = motion ? targetX : scrollTargetX;
|
|
1300
|
+
var overscrollY = motion ? targetY : scrollTargetY;
|
|
1301
|
+
if (mutableRef.current.overscrollEnabled && overscrollEffect) {
|
|
1302
|
+
if (scrollLeft !== overscrollX && canScrollHorizontally(bounds)) {
|
|
1303
|
+
checkAndApplyOverscrollEffectOnStart('horizontal', getEdgeFromPosition(overscrollX, maxLeft), overscrollX);
|
|
1304
|
+
}
|
|
1305
|
+
if (scrollTop !== overscrollY && canScrollVertically(bounds)) {
|
|
1306
|
+
checkAndApplyOverscrollEffectOnStart('vertical', getEdgeFromPosition(overscrollY, maxTop), overscrollY);
|
|
1307
|
+
}
|
|
1297
1308
|
}
|
|
1298
|
-
if (
|
|
1299
|
-
|
|
1309
|
+
if (scrollMode === 'translate') {
|
|
1310
|
+
showScrollbarTrack(bounds);
|
|
1311
|
+
if (scrollContentHandle.current && scrollContentHandle.current.setScrollPositionTarget) {
|
|
1312
|
+
scrollContentHandle.current.setScrollPositionTarget(scrollTargetX, scrollTargetY);
|
|
1313
|
+
}
|
|
1314
|
+
if (shouldAnimate) {
|
|
1315
|
+
mutableRef.current.animator.animate(scrollAnimation(mutableRef.current.animationInfo));
|
|
1316
|
+
} else {
|
|
1317
|
+
scroll(scrollTargetX, scrollTargetY);
|
|
1318
|
+
stop();
|
|
1319
|
+
}
|
|
1320
|
+
} else if (scrollContentHandle.current) {
|
|
1321
|
+
// scrollMode 'native'
|
|
1322
|
+
var _roundTarget = roundTarget(scrollContentHandle.current, scrollTargetX, scrollTargetY),
|
|
1323
|
+
roundedTargetX = _roundTarget.roundedTargetX,
|
|
1324
|
+
roundedTargetY = _roundTarget.roundedTargetY;
|
|
1325
|
+
if (shouldAnimate && motion && motion.duration > 0) {
|
|
1326
|
+
scrollContentRef.current.lastInputType = mutableRef.current.lastInputType;
|
|
1327
|
+
(0, _scrollMotion.startNativeScroll)(mutableRef.current, {
|
|
1328
|
+
fromX: scrollLeft,
|
|
1329
|
+
fromY: scrollTop,
|
|
1330
|
+
toX: roundedTargetX,
|
|
1331
|
+
toY: roundedTargetY,
|
|
1332
|
+
duration: motion.duration,
|
|
1333
|
+
ease: motion.ease,
|
|
1334
|
+
scrollTo: function scrollTo(x, y) {
|
|
1335
|
+
if (scrollContentHandle.current) {
|
|
1336
|
+
scrollContentHandle.current.scrollToPosition(x, y, 'instant');
|
|
1337
|
+
}
|
|
1338
|
+
}
|
|
1339
|
+
});
|
|
1340
|
+
} else if (shouldAnimate) {
|
|
1341
|
+
scrollContentRef.current.lastInputType = mutableRef.current.lastInputType;
|
|
1342
|
+
scrollContentHandle.current.scrollToPosition(roundedTargetX, roundedTargetY, 'smooth', mutableRef.current.repeat);
|
|
1343
|
+
} else {
|
|
1344
|
+
scrollContentHandle.current.scrollToPosition(roundedTargetX, roundedTargetY, 'instant');
|
|
1345
|
+
}
|
|
1346
|
+
if (props.start) {
|
|
1347
|
+
props.start(shouldAnimate);
|
|
1348
|
+
}
|
|
1300
1349
|
}
|
|
1350
|
+
};
|
|
1351
|
+
|
|
1352
|
+
// A token's delay is applied once, for both native and translate. Stop and unmount cancel it.
|
|
1353
|
+
if (motion && motion.delay > 0) {
|
|
1354
|
+
(0, _scrollMotion.cancelScrollMotion)(mutableRef.current);
|
|
1355
|
+
mutableRef.current.motionDelay = setTimeout(function () {
|
|
1356
|
+
mutableRef.current.motionDelay = null;
|
|
1357
|
+
begin(true);
|
|
1358
|
+
}, motion.delay);
|
|
1359
|
+
return;
|
|
1301
1360
|
}
|
|
1361
|
+
begin(false);
|
|
1302
1362
|
}
|
|
1303
1363
|
|
|
1304
1364
|
// scrollMode 'translate' [[
|
|
@@ -1309,12 +1369,15 @@ var useScrollBase = exports.useScrollBase = function useScrollBase(props) {
|
|
|
1309
1369
|
targetX = animationInfo.targetX,
|
|
1310
1370
|
targetY = animationInfo.targetY,
|
|
1311
1371
|
duration = animationInfo.duration,
|
|
1372
|
+
fixedDuration = animationInfo.fixedDuration,
|
|
1373
|
+
timingFunction = animationInfo.timingFunction,
|
|
1312
1374
|
bounds = getScrollBounds(),
|
|
1313
|
-
scrollAnimationDuration = mutableRef.current.keyPressed ? minAnimationDuration : duration
|
|
1375
|
+
scrollAnimationDuration = mutableRef.current.keyPressed ? minAnimationDuration : duration,
|
|
1376
|
+
timing = timingFunction || mutableRef.current.animator.timingFunction;
|
|
1314
1377
|
var dynamicScrollDuration = function dynamicScrollDuration(target, source) {
|
|
1315
1378
|
var customDuration = Math.max(minAnimationDuration, Math.abs(target - source));
|
|
1316
1379
|
if (mutableRef.current.keyPressed) return minAnimationDuration;
|
|
1317
|
-
return
|
|
1380
|
+
return fixedDuration ? duration : Math.min(customDuration, duration);
|
|
1318
1381
|
};
|
|
1319
1382
|
if (curTime < scrollAnimationDuration) {
|
|
1320
1383
|
var toBeContinued = false,
|
|
@@ -1322,7 +1385,7 @@ var useScrollBase = exports.useScrollBase = function useScrollBase(props) {
|
|
|
1322
1385
|
curTargetY = sourceY;
|
|
1323
1386
|
if (canScrollHorizontally(bounds)) {
|
|
1324
1387
|
var scrollDuration = dynamicScrollDuration(sourceX, targetX);
|
|
1325
|
-
curTargetX =
|
|
1388
|
+
curTargetX = timing(sourceX, targetX, scrollDuration, curTime, mutableRef.current.keyPressed);
|
|
1326
1389
|
if (Math.abs(curTargetX - targetX) < epsilon) {
|
|
1327
1390
|
curTargetX = targetX;
|
|
1328
1391
|
} else {
|
|
@@ -1331,7 +1394,7 @@ var useScrollBase = exports.useScrollBase = function useScrollBase(props) {
|
|
|
1331
1394
|
}
|
|
1332
1395
|
if (canScrollVertically(bounds)) {
|
|
1333
1396
|
var _scrollDuration = dynamicScrollDuration(sourceY, targetY);
|
|
1334
|
-
curTargetY =
|
|
1397
|
+
curTargetY = timing(sourceY, targetY, _scrollDuration, curTime, mutableRef.current.keyPressed);
|
|
1335
1398
|
if (Math.abs(curTargetY - targetY) < epsilon) {
|
|
1336
1399
|
curTargetY = targetY;
|
|
1337
1400
|
} else {
|
|
@@ -1380,6 +1443,7 @@ var useScrollBase = exports.useScrollBase = function useScrollBase(props) {
|
|
|
1380
1443
|
scrollContentHandle.current.scrollToPosition(mutableRef.current.scrollLeft + (rtl ? -0.1 : 0.1), mutableRef.current.scrollTop + 0.1, 'instant');
|
|
1381
1444
|
}
|
|
1382
1445
|
function stop() {
|
|
1446
|
+
(0, _scrollMotion.cancelScrollMotion)(mutableRef.current);
|
|
1383
1447
|
if (scrollMode === 'translate') {
|
|
1384
1448
|
stopForTranslate();
|
|
1385
1449
|
} else {
|