@enact/ui 5.5.0 → 5.5.2
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/CHANGELOG.md +26 -0
- package/Scroller/Scroller.d.ts +2 -2
- package/Scroller/ScrollerBasic.js +33 -14
- package/Scroller/tests/ScrollerBasic-specs.js +187 -14
- package/Transition/Transition.js +207 -190
- package/Transition/Transition.module.css +0 -5
- package/Transition/tests/Transition-specs.js +220 -0
- package/VirtualList/VirtualListBasic.js +119 -26
- package/VirtualList/tests/VirtualList-native-specs.js +219 -3
- package/package.json +7 -12
- package/resolution/ResolutionDecorator.js +2 -1
- package/resolution/index.d.ts +6 -4
- package/resolution/resolution.js +63 -35
- package/resolution/tests/resolution-specs.js +35 -7
- package/useScroll/tests/useScroll-specs.js +175 -6
- package/useScroll/useScroll.js +28 -12
package/useScroll/useScroll.js
CHANGED
|
@@ -24,7 +24,7 @@ var _utilEvent = _interopRequireDefault(require("./utilEvent"));
|
|
|
24
24
|
var _useScrollModule = _interopRequireDefault(require("./useScroll.module.css"));
|
|
25
25
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
26
26
|
var _excluded = ["ref"],
|
|
27
|
-
_excluded2 = ["childProps", "children", "className", "clientSize", "assignProperties", "dataSize", "direction", "horizontalScrollbar", "horizontalScrollbarHandle", "itemRenderer", "
|
|
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
28
|
/* global ResizeObserver */
|
|
29
29
|
/**
|
|
30
30
|
* Unstyled scrollable hook and behaviors to be customized by a theme or application.
|
|
@@ -138,6 +138,7 @@ function roundTarget(currentPosition, targetX, targetY) {
|
|
|
138
138
|
* @private
|
|
139
139
|
*/
|
|
140
140
|
var useScrollBase = exports.useScrollBase = function useScrollBase(props) {
|
|
141
|
+
var _scaledItemSizesRef$c;
|
|
141
142
|
var childProps = props.childProps,
|
|
142
143
|
children = props.children,
|
|
143
144
|
className = props.className,
|
|
@@ -148,7 +149,6 @@ var useScrollBase = exports.useScrollBase = function useScrollBase(props) {
|
|
|
148
149
|
horizontalScrollbar = props.horizontalScrollbar,
|
|
149
150
|
horizontalScrollbarHandle = props.horizontalScrollbarHandle,
|
|
150
151
|
itemRenderer = props.itemRenderer,
|
|
151
|
-
itemSizes = props.itemSizes,
|
|
152
152
|
noScrollByDrag = props.noScrollByDrag,
|
|
153
153
|
noScrollByWheel = props.noScrollByWheel,
|
|
154
154
|
overhang = props.overhang,
|
|
@@ -179,6 +179,7 @@ var useScrollBase = exports.useScrollBase = function useScrollBase(props) {
|
|
|
179
179
|
delete rest.clearOverscrollEffect;
|
|
180
180
|
delete rest.handleResizeWindow;
|
|
181
181
|
delete rest.itemSize;
|
|
182
|
+
delete rest.itemSizes;
|
|
182
183
|
delete rest.onFlick;
|
|
183
184
|
delete rest.onKeyDown;
|
|
184
185
|
delete rest.onMouseDown;
|
|
@@ -219,6 +220,12 @@ var useScrollBase = exports.useScrollBase = function useScrollBase(props) {
|
|
|
219
220
|
_useState0 = _slicedToArray(_useState9, 2),
|
|
220
221
|
itemSize = _useState0[0],
|
|
221
222
|
setItemSize = _useState0[1];
|
|
223
|
+
var scaledItemSizesRef = (0, _react.useRef)(null);
|
|
224
|
+
var scaledItemSizesSourceRef = (0, _react.useRef)(props.itemSizes);
|
|
225
|
+
if (scaledItemSizesSourceRef.current !== props.itemSizes) {
|
|
226
|
+
scaledItemSizesRef.current = null;
|
|
227
|
+
scaledItemSizesSourceRef.current = props.itemSizes;
|
|
228
|
+
}
|
|
222
229
|
var mutableRef = (0, _react.useRef)({
|
|
223
230
|
overscrollEnabled: !!props.applyOverscrollEffect,
|
|
224
231
|
// Enable the early bail out of repeated scrolling to the same position
|
|
@@ -464,7 +471,7 @@ var useScrollBase = exports.useScrollBase = function useScrollBase(props) {
|
|
|
464
471
|
dataSize: dataSize,
|
|
465
472
|
itemRenderer: itemRenderer,
|
|
466
473
|
itemSize: itemSize,
|
|
467
|
-
itemSizes: itemSizes,
|
|
474
|
+
itemSizes: (_scaledItemSizesRef$c = scaledItemSizesRef.current) !== null && _scaledItemSizesRef$c !== void 0 ? _scaledItemSizesRef$c : props.itemSizes,
|
|
468
475
|
overhang: overhang,
|
|
469
476
|
pageScroll: pageScroll,
|
|
470
477
|
spacing: spacing,
|
|
@@ -476,15 +483,18 @@ var useScrollBase = exports.useScrollBase = function useScrollBase(props) {
|
|
|
476
483
|
var propsHandleResizeWindow = props.handleResizeWindow;
|
|
477
484
|
if (_resolution["default"].scale(1) !== riRatio) {
|
|
478
485
|
if (scrollContentProps.itemSize) {
|
|
486
|
+
var ratio = _resolution["default"].scale(1) / riRatio;
|
|
479
487
|
if (scrollContentProps.itemSize.minWidth && scrollContentProps.itemSize.minHeight) {
|
|
480
|
-
scrollContentProps.itemSize
|
|
481
|
-
|
|
488
|
+
scrollContentProps.itemSize = _objectSpread(_objectSpread({}, scrollContentProps.itemSize), {}, {
|
|
489
|
+
minWidth: scrollContentProps.itemSize.minWidth * ratio,
|
|
490
|
+
minHeight: scrollContentProps.itemSize.minHeight * ratio
|
|
491
|
+
});
|
|
482
492
|
} else {
|
|
483
|
-
scrollContentProps.itemSize *=
|
|
493
|
+
scrollContentProps.itemSize *= ratio;
|
|
484
494
|
if (scrollContentProps.itemSizes) {
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
}
|
|
495
|
+
scaledItemSizesRef.current = scrollContentProps.itemSizes.map(function (s) {
|
|
496
|
+
return s * ratio;
|
|
497
|
+
});
|
|
488
498
|
}
|
|
489
499
|
}
|
|
490
500
|
setItemSize(scrollContentProps.itemSize);
|
|
@@ -918,7 +928,8 @@ var useScrollBase = exports.useScrollBase = function useScrollBase(props) {
|
|
|
918
928
|
* Handler for scrollend event
|
|
919
929
|
*/
|
|
920
930
|
function onScrollEnd(ev) {
|
|
921
|
-
|
|
931
|
+
var _scrollContentHandle$;
|
|
932
|
+
if (!mutableRef.current.scrolling || mutableRef.current.keyPressed || (_scrollContentHandle$ = scrollContentHandle.current) !== null && _scrollContentHandle$ !== void 0 && _scrollContentHandle$.scrolling) {
|
|
922
933
|
return;
|
|
923
934
|
}
|
|
924
935
|
updateScrollPosition(ev);
|
|
@@ -927,7 +938,7 @@ var useScrollBase = exports.useScrollBase = function useScrollBase(props) {
|
|
|
927
938
|
mutableRef.current.scrollStopJob.stop();
|
|
928
939
|
|
|
929
940
|
// stop for non-accumulating scrolls (mouse/touch)
|
|
930
|
-
if (!mutableRef.current.isScrollAnimationTargetAccumulated) {
|
|
941
|
+
if (!mutableRef.current.isScrollAnimationTargetAccumulated && !mutableRef.current.keyScroll) {
|
|
931
942
|
scrollStopOnScroll();
|
|
932
943
|
return;
|
|
933
944
|
}
|
|
@@ -938,6 +949,7 @@ var useScrollBase = exports.useScrollBase = function useScrollBase(props) {
|
|
|
938
949
|
}
|
|
939
950
|
mutableRef.current.scrollEndGraceTimer = setTimeout(function () {
|
|
940
951
|
mutableRef.current.scrollEndGraceTimer = null;
|
|
952
|
+
mutableRef.current.keyScroll = false;
|
|
941
953
|
scrollStopOnScroll();
|
|
942
954
|
}, 100);
|
|
943
955
|
}
|
|
@@ -955,12 +967,15 @@ var useScrollBase = exports.useScrollBase = function useScrollBase(props) {
|
|
|
955
967
|
var _props$preventScroll;
|
|
956
968
|
(_props$preventScroll = props.preventScroll) === null || _props$preventScroll === void 0 || _props$preventScroll.call(props, ev);
|
|
957
969
|
mutableRef.current.repeat = ev.repeat;
|
|
958
|
-
|
|
970
|
+
var isArrowKey = mutableRef.current.lastInputType === 'arrowKey';
|
|
971
|
+
var isPageKey = mutableRef.current.lastInputType === 'pageKey';
|
|
972
|
+
if (ev.repeat && (isArrowKey || isPageKey)) return;
|
|
959
973
|
(0, _handle.forward)('onKeyDown', ev, props);
|
|
960
974
|
}
|
|
961
975
|
}
|
|
962
976
|
function onKeyUp(ev) {
|
|
963
977
|
mutableRef.current.keyPressed = false;
|
|
978
|
+
mutableRef.current.keyScroll = true;
|
|
964
979
|
(0, _handle.forward)('onKeyUp', ev, props);
|
|
965
980
|
}
|
|
966
981
|
function scrollToAccumulatedTarget(delta, vertical, overscrollEffect) {
|
|
@@ -1275,6 +1290,7 @@ var useScrollBase = exports.useScrollBase = function useScrollBase(props) {
|
|
|
1275
1290
|
roundedTargetX = _roundTarget.roundedTargetX,
|
|
1276
1291
|
roundedTargetY = _roundTarget.roundedTargetY;
|
|
1277
1292
|
if (animate) {
|
|
1293
|
+
scrollContentRef.current.lastInputType = mutableRef.current.lastInputType;
|
|
1278
1294
|
scrollContentHandle.current.scrollToPosition(roundedTargetX, roundedTargetY, 'smooth', mutableRef.current.repeat);
|
|
1279
1295
|
} else {
|
|
1280
1296
|
scrollContentHandle.current.scrollToPosition(roundedTargetX, roundedTargetY, 'instant');
|