@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.
Files changed (121) hide show
  1. package/AnnounceDecorator/Announce.js +8 -8
  2. package/AnnounceDecorator/AnnounceDecorator.js +5 -5
  3. package/BodyText/BodyText.js +5 -5
  4. package/BodyText/tests/BodyText-specs.js +2 -1
  5. package/Button/Button.js +5 -5
  6. package/CHANGELOG.md +18 -0
  7. package/Cancelable/Cancelable.js +9 -9
  8. package/Cancelable/tests/Cancelable-specs.js +5 -5
  9. package/Card/Card.js +5 -5
  10. package/Card/tests/Card-specs.js +2 -1
  11. package/Changeable/Changeable.js +9 -9
  12. package/ComponentOverride/ComponentOverride.js +15 -11
  13. package/FloatingLayer/FloatingLayer.js +10 -10
  14. package/FloatingLayer/FloatingLayerContainer.js +3 -3
  15. package/FloatingLayer/FloatingLayerDecorator.js +5 -5
  16. package/FloatingLayer/Scrim.js +9 -9
  17. package/FloatingLayer/tests/useFloatingLayerDecorator-specs.js +4 -4
  18. package/FloatingLayer/useFloatingLayer.js +3 -4
  19. package/ForwardRef/ForwardRef.js +5 -5
  20. package/Group/Group.js +5 -5
  21. package/Group/GroupItem.js +5 -5
  22. package/Group/tests/Group-specs.js +2 -1
  23. package/Heading/Heading.js +5 -5
  24. package/Icon/Icon.js +5 -5
  25. package/Icon/tests/Icon-specs.js +2 -1
  26. package/Image/Image.js +5 -5
  27. package/Image/tests/Image-specs.js +2 -1
  28. package/ImageItem/ImageItem.js +5 -5
  29. package/ImageItem/tests/ImageItem-specs.js +6 -5
  30. package/Item/Item.js +5 -5
  31. package/LabeledIcon/LabeledIcon.js +5 -5
  32. package/Layout/Cell.js +5 -5
  33. package/Layout/Layout.js +5 -5
  34. package/Layout/tests/Layout-specs.js +9 -9
  35. package/Marquee/Marquee.module.css +44 -0
  36. package/Marquee/MarqueeBase.js +134 -21
  37. package/Marquee/MarqueeController.js +4 -4
  38. package/Marquee/MarqueeDecorator.js +219 -27
  39. package/Marquee/index.d.ts +60 -12
  40. package/Marquee/tests/Marquee-specs.js +3 -3
  41. package/Marquee/tests/Marquee-vertical-specs.js +1358 -0
  42. package/Marquee/useMarqueeController.js +4 -4
  43. package/Marquee/utils.js +22 -0
  44. package/Marquee/verticalMeasure.js +118 -0
  45. package/Measurable/Measurable.js +8 -9
  46. package/Measurable/tests/Measurable-specs.js +7 -6
  47. package/Media/Media.js +10 -10
  48. package/Placeholder/PlaceholderControllerDecorator.js +9 -9
  49. package/Placeholder/PlaceholderDecorator.js +9 -9
  50. package/Placeholder/tests/PlaceholderControllerDecorator-specs.js +4 -4
  51. package/ProgressBar/ProgressBar.js +5 -5
  52. package/Repeater/Repeater.js +5 -5
  53. package/Repeater/tests/Repeater-specs.js +6 -5
  54. package/Resizable/Resizable.js +4 -4
  55. package/Resizable/tests/Resizable-specs.js +2 -1
  56. package/Resizable/tests/useResize-specs.js +4 -4
  57. package/Resizable/useResize.js +3 -3
  58. package/Routable/Link.js +9 -9
  59. package/Routable/Routable.js +5 -5
  60. package/Routable/Router.js +9 -9
  61. package/Routable/tests/Routable-specs.js +7 -8
  62. package/Routable/tests/Router-specs.js +1 -1
  63. package/Scroller/Scroller.js +4 -4
  64. package/Scroller/ScrollerBasic.js +10 -10
  65. package/Skinnable/Skinnable.js +5 -5
  66. package/Skinnable/tests/Skinnable-specs.js +4 -4
  67. package/Skinnable/tests/useSkins-specs.js +4 -4
  68. package/Slider/Knob.js +5 -5
  69. package/Slider/PositionDecorator.js +8 -8
  70. package/Slider/Slider.js +5 -5
  71. package/Slottable/Slottable.js +4 -4
  72. package/Slottable/useSlots.js +5 -5
  73. package/Spinner/Spinner.js +5 -5
  74. package/ToggleIcon/ToggleIcon.js +5 -5
  75. package/Toggleable/Toggle.js +5 -5
  76. package/Toggleable/Toggleable.js +9 -9
  77. package/Toggleable/useToggle.js +5 -5
  78. package/Touchable/ClickAllow.js +3 -3
  79. package/Touchable/Drag.js +6 -6
  80. package/Touchable/Flick.js +5 -5
  81. package/Touchable/Hold.js +5 -5
  82. package/Touchable/Pinch.js +6 -6
  83. package/Touchable/Touch.js +3 -3
  84. package/Touchable/Touchable.js +5 -5
  85. package/Touchable/config.js +4 -4
  86. package/Touchable/tests/Touchable-specs.js +1 -1
  87. package/Touchable/tests/useTouch-specs.js +5 -5
  88. package/Touchable/useTouch.js +7 -8
  89. package/Transition/Transition.js +14 -13
  90. package/Transition/tests/Transition-specs.js +9 -9
  91. package/ViewManager/Arranger.js +4 -4
  92. package/ViewManager/TransitionGroup.js +7 -7
  93. package/ViewManager/View.js +9 -9
  94. package/ViewManager/ViewManager.js +11 -10
  95. package/ViewManager/tests/ViewManager-specs.js +6 -6
  96. package/VirtualList/VirtualList.js +4 -4
  97. package/VirtualList/VirtualListBasic.js +67 -47
  98. package/VirtualList/tests/VirtualGridList-native-specs.js +5 -5
  99. package/VirtualList/tests/VirtualGridList-specs.js +16 -15
  100. package/VirtualList/tests/VirtualList-native-specs.js +164 -16
  101. package/VirtualList/tests/VirtualList-specs.js +16 -15
  102. package/internal/IdProvider/IdProvider.js +4 -4
  103. package/internal/IdProvider/Provider.js +3 -3
  104. package/internal/IdProvider/tests/IdProvider-specs.js +4 -4
  105. package/internal/IdProvider/tests/useId-specs.js +16 -8
  106. package/internal/Pure/Pure.js +9 -9
  107. package/internal/Pure/tests/Pure-specs.js +8 -8
  108. package/internal/localized-fonts/localized-fonts.js +3 -4
  109. package/package.json +6 -6
  110. package/resolution/ResolutionDecorator.js +71 -87
  111. package/resolution/index.js +2 -1
  112. package/resolution/tests/resolution-specs.js +7 -8
  113. package/useControlledState/tests/useControlledState-specs.js +3 -4
  114. package/useControlledState/useControlledState.js +3 -4
  115. package/useScroll/ScrollAnimator.js +3 -3
  116. package/useScroll/Scrollbar.js +5 -5
  117. package/useScroll/ScrollbarTrack.js +5 -5
  118. package/useScroll/scrollMotion.js +126 -0
  119. package/useScroll/tests/scrollMotion-specs.js +215 -0
  120. package/useScroll/tests/useScroll-specs.js +430 -9
  121. package/useScroll/useScroll.js +156 -92
@@ -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(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
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(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
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, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
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(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
49
- function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
50
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
51
- function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
52
- function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
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 _mutableRef$current = mutableRef.current,
429
- animator = _mutableRef$current.animator,
430
- resizeRegistry = _mutableRef$current.resizeRegistry,
431
- scrolling = _mutableRef$current.scrolling,
432
- scrollStopJob = _mutableRef$current.scrollStopJob; // eslint-disable-line react-hooks/exhaustive-deps
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$current2 = mutableRef.current,
554
- prevState = _mutableRef$current2.prevState,
555
- resizeRegistry = _mutableRef$current2.resizeRegistry,
556
- scrollToInfo = _mutableRef$current2.scrollToInfo;
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 = 0;
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(_ref2) {
1224
- var targetX = _ref2.targetX,
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
- _ref2$duration = _ref2.duration,
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 _mutableRef$current3 = mutableRef.current,
1233
- scrollLeft = _mutableRef$current3.scrollLeft,
1234
- scrollTop = _mutableRef$current3.scrollTop,
1235
- bounds = getScrollBounds(),
1236
- maxLeft = bounds.maxLeft,
1237
- maxTop = bounds.maxTop;
1238
- var updatedAnimationInfo = scrollMode === 'translate' ? {
1239
- sourceX: scrollLeft,
1240
- sourceY: scrollTop,
1241
- targetX: targetX,
1242
- targetY: targetY,
1243
- duration: duration
1244
- } : {
1245
- targetX: targetX,
1246
- targetY: targetY
1247
- };
1248
-
1249
- // bail early when scrolling to the same position
1250
- if ((scrollMode === 'translate' && mutableRef.current.animator.isAnimating() || scrollMode === 'native' && mutableRef.current.scrolling) && mutableRef.current.animationInfo && mutableRef.current.animationInfo.targetX === targetX && mutableRef.current.animationInfo.targetY === targetY) {
1251
- return;
1252
- }
1253
- mutableRef.current.animationInfo = updatedAnimationInfo;
1254
- if (scrollMode === 'translate') {
1255
- mutableRef.current.animator.stop();
1256
- if (!mutableRef.current.scrolling) {
1257
- mutableRef.current.scrolling = true;
1258
- forwardScrollEvent('onScrollStart');
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
- mutableRef.current.scrollStopJob.stop();
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 (scrollTop !== targetY && canScrollVertically(bounds)) {
1273
- checkAndApplyOverscrollEffectOnStart('vertical', getEdgeFromPosition(targetY, maxTop), targetY);
1266
+ if (Math.abs(maxTop - scrollTargetY) < epsilon) {
1267
+ scrollTargetY = maxTop;
1274
1268
  }
1275
- }
1276
- if (scrollMode === 'translate') {
1277
- showScrollbarTrack(bounds);
1278
- if (scrollContentHandle.current && scrollContentHandle.current.setScrollPositionTarget) {
1279
- scrollContentHandle.current.setScrollPositionTarget(targetX, targetY);
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
- if (animate) {
1282
- mutableRef.current.animator.animate(scrollAnimation(mutableRef.current.animationInfo));
1283
- } else {
1284
- scroll(targetX, targetY);
1285
- stop();
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
- } else {
1288
- // scrollMode 'native'
1289
- var _roundTarget = roundTarget(scrollContentHandle.current, targetX, targetY),
1290
- roundedTargetX = _roundTarget.roundedTargetX,
1291
- roundedTargetY = _roundTarget.roundedTargetY;
1292
- if (animate) {
1293
- scrollContentRef.current.lastInputType = mutableRef.current.lastInputType;
1294
- scrollContentHandle.current.scrollToPosition(roundedTargetX, roundedTargetY, 'smooth', mutableRef.current.repeat);
1295
- } else {
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 (props.start) {
1299
- props.start(animate);
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 animationDuration !== duration ? duration : Math.min(customDuration, duration);
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 = mutableRef.current.animator.timingFunction(sourceX, targetX, scrollDuration, curTime, mutableRef.current.keyPressed);
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 = mutableRef.current.animator.timingFunction(sourceY, targetY, _scrollDuration, curTime, mutableRef.current.keyPressed);
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 {