@enact/ui 5.3.2 → 5.4.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/CHANGELOG.md +11 -0
- package/Card/Card.d.ts +5 -0
- package/Card/Card.js +12 -0
- package/Card/Card.module.css +3 -0
- package/Slider/Slider.d.ts +4 -0
- package/Slider/Slider.js +21 -5
- package/Slider/Slider.module.css +2 -1
- package/package.json +7 -7
- package/resolution/tests/resolution-specs.js +172 -5
- package/useScroll/ScrollAnimator.js +11 -2
- package/useScroll/useScroll.js +21 -4
- package/useScroll/utilAnimation.js +47 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,17 @@
|
|
|
2
2
|
|
|
3
3
|
The following is a curated list of changes in the Enact ui module, newest changes on the top.
|
|
4
4
|
|
|
5
|
+
## [5.4.0] - 2025-12-08
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
|
|
9
|
+
- `limestone/Card` `splitCaption` prop to allow user to split the content for the captions
|
|
10
|
+
- `ui/useScroll.ScrollAnimator` `oase-out-cubic` animation function
|
|
11
|
+
|
|
12
|
+
### Changed
|
|
13
|
+
|
|
14
|
+
- `ui/useScroll.ScrollAnimator` default animation function
|
|
15
|
+
|
|
5
16
|
## [5.3.2] - 2025-10-28
|
|
6
17
|
|
|
7
18
|
No significant changes.
|
package/Card/Card.d.ts
CHANGED
|
@@ -50,6 +50,11 @@ corresponding internal elements and states of this component.
|
|
|
50
50
|
*/
|
|
51
51
|
selected?: boolean;
|
|
52
52
|
/**
|
|
53
|
+
* Splits the captions in two sections. This prop is only used when
|
|
54
|
+
`captionOverlayOnFocus` or `captionOverlay` is `true` and `orientation` is `'vertical'` .
|
|
55
|
+
*/
|
|
56
|
+
splitCaption?: boolean;
|
|
57
|
+
/**
|
|
53
58
|
* String value or object of values used to determine which image will appear on a specific
|
|
54
59
|
screenSize.
|
|
55
60
|
*/
|
package/Card/Card.js
CHANGED
|
@@ -123,6 +123,15 @@ var CardBase = exports.CardBase = (0, _kind["default"])({
|
|
|
123
123
|
* @public
|
|
124
124
|
*/
|
|
125
125
|
selected: _propTypes2["default"].bool,
|
|
126
|
+
/**
|
|
127
|
+
* Splits the captions in two sections. This prop is only used when
|
|
128
|
+
* `captionOverlayOnFocus` or `captionOverlay` is `true` and `orientation` is `'vertical'`.
|
|
129
|
+
*
|
|
130
|
+
* @type {Boolean}
|
|
131
|
+
* @default false
|
|
132
|
+
* @public
|
|
133
|
+
*/
|
|
134
|
+
splitCaption: _propTypes2["default"].bool,
|
|
126
135
|
/**
|
|
127
136
|
* String value or object of values used to determine which image will appear on a specific
|
|
128
137
|
* screenSize.
|
|
@@ -146,6 +155,7 @@ var CardBase = exports.CardBase = (0, _kind["default"])({
|
|
|
146
155
|
var captionOverlay = _ref2.captionOverlay,
|
|
147
156
|
fitImage = _ref2.fitImage,
|
|
148
157
|
orientation = _ref2.orientation,
|
|
158
|
+
splitCaption = _ref2.splitCaption,
|
|
149
159
|
selected = _ref2.selected,
|
|
150
160
|
styler = _ref2.styler;
|
|
151
161
|
return styler.append({
|
|
@@ -153,6 +163,7 @@ var CardBase = exports.CardBase = (0, _kind["default"])({
|
|
|
153
163
|
selected: selected,
|
|
154
164
|
fitImage: fitImage,
|
|
155
165
|
horizontal: orientation === 'horizontal',
|
|
166
|
+
splitCaption: splitCaption && orientation === 'vertical',
|
|
156
167
|
vertical: orientation === 'vertical'
|
|
157
168
|
});
|
|
158
169
|
}
|
|
@@ -168,6 +179,7 @@ var CardBase = exports.CardBase = (0, _kind["default"])({
|
|
|
168
179
|
src = _ref3.src,
|
|
169
180
|
rest = _objectWithoutProperties(_ref3, _excluded2);
|
|
170
181
|
delete rest.fitImage;
|
|
182
|
+
delete rest.splitCaption;
|
|
171
183
|
var isHorizontal = orientation === 'horizontal';
|
|
172
184
|
var isCaptionOverlay = captionOverlay && !isHorizontal;
|
|
173
185
|
var Component = isHorizontal ? _Layout.Row : _Layout.Column;
|
package/Card/Card.module.css
CHANGED
package/Slider/Slider.d.ts
CHANGED
|
@@ -118,6 +118,10 @@ will have its props merged with the above props.
|
|
|
118
118
|
.
|
|
119
119
|
*/
|
|
120
120
|
min?: number;
|
|
121
|
+
/**
|
|
122
|
+
* Adds a child component to the slider which should show the min and max values.
|
|
123
|
+
*/
|
|
124
|
+
minMaxComponent?: React.ComponentType | JSX.Element;
|
|
121
125
|
/**
|
|
122
126
|
* Applies the style where the slider bar does not display filled.
|
|
123
127
|
*/
|
package/Slider/Slider.js
CHANGED
|
@@ -23,7 +23,7 @@ var _PositionDecorator = _interopRequireDefault(require("./PositionDecorator"));
|
|
|
23
23
|
var _SliderModule = _interopRequireDefault(require("./Slider.module.css"));
|
|
24
24
|
var _utils = require("./utils");
|
|
25
25
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
26
|
-
var _excluded = ["backgroundProgress", "componentRef", "css", "disabled", "knobComponent", "min", "orientation", "percent", "progressBarComponent", "progressAnchor", "tooltipComponent", "value"];
|
|
26
|
+
var _excluded = ["backgroundProgress", "componentRef", "css", "disabled", "knobComponent", "max", "min", "minMaxComponent", "orientation", "percent", "progressBarComponent", "progressAnchor", "tooltipComponent", "value"];
|
|
27
27
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
28
28
|
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; }
|
|
29
29
|
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; }
|
|
@@ -159,6 +159,15 @@ var SliderBase = exports.SliderBase = (0, _kind["default"])({
|
|
|
159
159
|
* @public
|
|
160
160
|
*/
|
|
161
161
|
min: _propTypes2["default"].number,
|
|
162
|
+
/**
|
|
163
|
+
* Adds a child component to the slider which should show the min and max values.
|
|
164
|
+
*
|
|
165
|
+
* @see {@link ui/ComponentOverride}
|
|
166
|
+
*
|
|
167
|
+
* @type {Component|Element}
|
|
168
|
+
* @public
|
|
169
|
+
*/
|
|
170
|
+
minMaxComponent: _propTypes["default"].componentOverride,
|
|
162
171
|
/**
|
|
163
172
|
* Applies the style where the slider bar does not display filled.
|
|
164
173
|
*
|
|
@@ -290,7 +299,9 @@ var SliderBase = exports.SliderBase = (0, _kind["default"])({
|
|
|
290
299
|
css = _ref4.css,
|
|
291
300
|
disabled = _ref4.disabled,
|
|
292
301
|
knobComponent = _ref4.knobComponent,
|
|
302
|
+
max = _ref4.max,
|
|
293
303
|
min = _ref4.min,
|
|
304
|
+
minMaxComponent = _ref4.minMaxComponent,
|
|
294
305
|
orientation = _ref4.orientation,
|
|
295
306
|
percent = _ref4.percent,
|
|
296
307
|
progressBarComponent = _ref4.progressBarComponent,
|
|
@@ -299,14 +310,13 @@ var SliderBase = exports.SliderBase = (0, _kind["default"])({
|
|
|
299
310
|
_ref4$value = _ref4.value,
|
|
300
311
|
value = _ref4$value === void 0 ? min : _ref4$value,
|
|
301
312
|
rest = _objectWithoutProperties(_ref4, _excluded);
|
|
302
|
-
delete rest.max;
|
|
303
313
|
delete rest.noFill;
|
|
304
314
|
delete rest.pressed;
|
|
305
315
|
delete rest.step;
|
|
306
|
-
return /*#__PURE__*/(0, _jsxRuntime.
|
|
316
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", _objectSpread(_objectSpread({}, rest), {}, {
|
|
307
317
|
disabled: disabled,
|
|
308
318
|
ref: componentRef,
|
|
309
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_ComponentOverride["default"], {
|
|
319
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_ComponentOverride["default"], {
|
|
310
320
|
backgroundProgress: backgroundProgress,
|
|
311
321
|
component: progressBarComponent,
|
|
312
322
|
orientation: orientation,
|
|
@@ -321,7 +331,13 @@ var SliderBase = exports.SliderBase = (0, _kind["default"])({
|
|
|
321
331
|
tooltipComponent: tooltipComponent,
|
|
322
332
|
value: value
|
|
323
333
|
})
|
|
324
|
-
})
|
|
334
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ComponentOverride["default"], {
|
|
335
|
+
className: css.minMax,
|
|
336
|
+
component: minMaxComponent,
|
|
337
|
+
orientation: orientation,
|
|
338
|
+
max: max,
|
|
339
|
+
min: min
|
|
340
|
+
})]
|
|
325
341
|
}));
|
|
326
342
|
}
|
|
327
343
|
});
|
package/Slider/Slider.module.css
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@enact/ui",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.4.0",
|
|
4
4
|
"description": "A collection of simplified unstyled cross-platform UI components for Enact",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -32,16 +32,16 @@
|
|
|
32
32
|
}
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@enact/core": "^5.
|
|
36
|
-
"@enact/i18n": "^5.
|
|
35
|
+
"@enact/core": "^5.4.0",
|
|
36
|
+
"@enact/i18n": "^5.4.0",
|
|
37
37
|
"classnames": "^2.5.1",
|
|
38
|
-
"ilib": "^14.21.
|
|
38
|
+
"ilib": "^14.21.2",
|
|
39
39
|
"invariant": "^2.2.4",
|
|
40
40
|
"prop-types": "^15.8.1",
|
|
41
41
|
"ramda": "^0.31.3",
|
|
42
|
-
"react": "^19.
|
|
43
|
-
"react-dom": "^19.
|
|
44
|
-
"react-is": "^19.
|
|
42
|
+
"react": "^19.2.0",
|
|
43
|
+
"react-dom": "^19.2.0",
|
|
44
|
+
"react-is": "^19.2.0",
|
|
45
45
|
"warning": "^4.0.3"
|
|
46
46
|
}
|
|
47
47
|
}
|
|
@@ -57,6 +57,12 @@ describe('Resolution Specs', function () {
|
|
|
57
57
|
height: 2160,
|
|
58
58
|
aspectRatioName: 'hdtv',
|
|
59
59
|
base: true
|
|
60
|
+
}, {
|
|
61
|
+
name: 'wuhd',
|
|
62
|
+
pxPerRem: 48,
|
|
63
|
+
width: 5158,
|
|
64
|
+
height: 2160,
|
|
65
|
+
aspectRatioName: 'cinema'
|
|
60
66
|
}, {
|
|
61
67
|
name: 'uhd2',
|
|
62
68
|
pxPerRem: 96,
|
|
@@ -100,6 +106,10 @@ describe('Resolution Specs', function () {
|
|
|
100
106
|
width: 3840,
|
|
101
107
|
height: 2160
|
|
102
108
|
};
|
|
109
|
+
var WUHD = {
|
|
110
|
+
width: 5158,
|
|
111
|
+
height: 2160
|
|
112
|
+
};
|
|
103
113
|
var UHD2 = {
|
|
104
114
|
width: 7680,
|
|
105
115
|
height: 4320
|
|
@@ -116,6 +126,7 @@ describe('Resolution Specs', function () {
|
|
|
116
126
|
expect((0, _resolution.getScreenType)(QHD)).toBe('qhd');
|
|
117
127
|
expect((0, _resolution.getScreenType)(WQHD)).toBe('wqhd');
|
|
118
128
|
expect((0, _resolution.getScreenType)(UHD)).toBe('uhd');
|
|
129
|
+
expect((0, _resolution.getScreenType)(WUHD)).toBe('wuhd');
|
|
119
130
|
expect((0, _resolution.getScreenType)(UHD2)).toBe('uhd2');
|
|
120
131
|
});
|
|
121
132
|
test('should select screen type whose height and width are both smaller than or same with the screen if `matchSmallerScreenType` true', function () {
|
|
@@ -216,6 +227,26 @@ describe('Resolution Specs', function () {
|
|
|
216
227
|
width: HD.width + 1,
|
|
217
228
|
height: XGA.height + 1
|
|
218
229
|
})).toBe('hd');
|
|
230
|
+
expect((0, _resolution.getScreenType)({
|
|
231
|
+
width: UWHD.width - 1,
|
|
232
|
+
height: UWHD.height - 1
|
|
233
|
+
})).toBe('hd');
|
|
234
|
+
expect((0, _resolution.getScreenType)({
|
|
235
|
+
width: UWHD.width + 1,
|
|
236
|
+
height: UWHD.height - 1
|
|
237
|
+
})).toBe('hd');
|
|
238
|
+
expect((0, _resolution.getScreenType)({
|
|
239
|
+
width: UWHD.width - 1,
|
|
240
|
+
height: UWHD.height + 1
|
|
241
|
+
})).toBe('hd');
|
|
242
|
+
expect((0, _resolution.getScreenType)({
|
|
243
|
+
width: UWUXGA.width - 1,
|
|
244
|
+
height: UWHD.height - 1
|
|
245
|
+
})).toBe('hd');
|
|
246
|
+
expect((0, _resolution.getScreenType)({
|
|
247
|
+
width: UWUXGA.width + 1,
|
|
248
|
+
height: UWHD.height - 1
|
|
249
|
+
})).toBe('hd');
|
|
219
250
|
expect((0, _resolution.getScreenType)({
|
|
220
251
|
width: FHD.width - 1,
|
|
221
252
|
height: FHD.height - 1
|
|
@@ -230,6 +261,14 @@ describe('Resolution Specs', function () {
|
|
|
230
261
|
width: UWHD.width + 1,
|
|
231
262
|
height: UWHD.height + 1
|
|
232
263
|
})).toBe('uw-hd');
|
|
264
|
+
expect((0, _resolution.getScreenType)({
|
|
265
|
+
width: UWUXGA.width - 1,
|
|
266
|
+
height: UWHD.height + 1
|
|
267
|
+
})).toBe('uw-hd');
|
|
268
|
+
expect((0, _resolution.getScreenType)({
|
|
269
|
+
width: UWUXGA.width + 1,
|
|
270
|
+
height: UWHD.height + 1
|
|
271
|
+
})).toBe('uw-hd');
|
|
233
272
|
expect((0, _resolution.getScreenType)({
|
|
234
273
|
width: FHD.width + 1,
|
|
235
274
|
height: FHD.height - 1
|
|
@@ -311,6 +350,22 @@ describe('Resolution Specs', function () {
|
|
|
311
350
|
width: UHD.width - 1,
|
|
312
351
|
height: UHD.height + 1
|
|
313
352
|
})).toBe('wqhd');
|
|
353
|
+
expect((0, _resolution.getScreenType)({
|
|
354
|
+
width: WUHD.width - 1,
|
|
355
|
+
height: WUHD.height - 1
|
|
356
|
+
})).toBe('wqhd');
|
|
357
|
+
expect((0, _resolution.getScreenType)({
|
|
358
|
+
width: WUHD.width + 1,
|
|
359
|
+
height: WUHD.height - 1
|
|
360
|
+
})).toBe('wqhd');
|
|
361
|
+
expect((0, _resolution.getScreenType)({
|
|
362
|
+
width: UHD2.width - 1,
|
|
363
|
+
height: WUHD.height - 1
|
|
364
|
+
})).toBe('wqhd');
|
|
365
|
+
expect((0, _resolution.getScreenType)({
|
|
366
|
+
width: UHD2.width + 1,
|
|
367
|
+
height: WUHD.height - 1
|
|
368
|
+
})).toBe('wqhd');
|
|
314
369
|
|
|
315
370
|
// UHD
|
|
316
371
|
expect((0, _resolution.getScreenType)({
|
|
@@ -318,17 +373,51 @@ describe('Resolution Specs', function () {
|
|
|
318
373
|
height: UHD.height + 1
|
|
319
374
|
})).toBe('uhd');
|
|
320
375
|
expect((0, _resolution.getScreenType)({
|
|
321
|
-
width:
|
|
376
|
+
width: WUHD.width - 1,
|
|
377
|
+
height: WUHD.height + 1
|
|
378
|
+
})).toBe('uhd');
|
|
379
|
+
expect((0, _resolution.getScreenType)({
|
|
380
|
+
width: WUHD.width - 1,
|
|
322
381
|
height: UHD2.height - 1
|
|
323
382
|
})).toBe('uhd');
|
|
383
|
+
expect((0, _resolution.getScreenType)({
|
|
384
|
+
width: WUHD.width - 1,
|
|
385
|
+
height: UHD2.height + 1
|
|
386
|
+
})).toBe('uhd');
|
|
387
|
+
|
|
388
|
+
// WUHD
|
|
389
|
+
expect((0, _resolution.getScreenType)({
|
|
390
|
+
width: WUHD.width + 1,
|
|
391
|
+
height: WUHD.height + 1
|
|
392
|
+
})).toBe('wuhd');
|
|
393
|
+
expect((0, _resolution.getScreenType)({
|
|
394
|
+
width: WUHD.width + 1,
|
|
395
|
+
height: UHD2.height - 1
|
|
396
|
+
})).toBe('wuhd');
|
|
397
|
+
expect((0, _resolution.getScreenType)({
|
|
398
|
+
width: WUHD.width + 1,
|
|
399
|
+
height: UHD2.height + 1
|
|
400
|
+
})).toBe('wuhd');
|
|
401
|
+
expect((0, _resolution.getScreenType)({
|
|
402
|
+
width: UHD2.width - 1,
|
|
403
|
+
height: WUHD.height + 1
|
|
404
|
+
})).toBe('wuhd');
|
|
405
|
+
expect((0, _resolution.getScreenType)({
|
|
406
|
+
width: UHD2.width + 1,
|
|
407
|
+
height: WUHD.height + 1
|
|
408
|
+
})).toBe('wuhd');
|
|
409
|
+
expect((0, _resolution.getScreenType)({
|
|
410
|
+
width: UHD2.width - 1,
|
|
411
|
+
height: UHD2.height - 1
|
|
412
|
+
})).toBe('wuhd');
|
|
324
413
|
expect((0, _resolution.getScreenType)({
|
|
325
414
|
width: UHD2.width + 1,
|
|
326
415
|
height: UHD2.height - 1
|
|
327
|
-
})).toBe('
|
|
416
|
+
})).toBe('wuhd');
|
|
328
417
|
expect((0, _resolution.getScreenType)({
|
|
329
418
|
width: UHD2.width - 1,
|
|
330
419
|
height: UHD2.height + 1
|
|
331
|
-
})).toBe('
|
|
420
|
+
})).toBe('wuhd');
|
|
332
421
|
|
|
333
422
|
// UHD2
|
|
334
423
|
expect((0, _resolution.getScreenType)({
|
|
@@ -444,12 +533,32 @@ describe('Resolution Specs', function () {
|
|
|
444
533
|
})).toBe('uw-hd');
|
|
445
534
|
|
|
446
535
|
// FHD
|
|
536
|
+
expect((0, _resolution.getScreenType)({
|
|
537
|
+
width: UWHD.width - 1,
|
|
538
|
+
height: UWHD.height + 1
|
|
539
|
+
})).toBe('fhd');
|
|
447
540
|
expect((0, _resolution.getScreenType)({
|
|
448
541
|
width: FHD.width - 1,
|
|
449
542
|
height: FHD.height - 1
|
|
450
543
|
})).toBe('fhd');
|
|
451
544
|
|
|
452
545
|
// UWUXGA
|
|
546
|
+
expect((0, _resolution.getScreenType)({
|
|
547
|
+
width: UWHD.width + 1,
|
|
548
|
+
height: UWHD.height - 1
|
|
549
|
+
})).toBe('uw-uxga');
|
|
550
|
+
expect((0, _resolution.getScreenType)({
|
|
551
|
+
width: UWHD.width + 1,
|
|
552
|
+
height: UWHD.height + 1
|
|
553
|
+
})).toBe('uw-uxga');
|
|
554
|
+
expect((0, _resolution.getScreenType)({
|
|
555
|
+
width: UWUXGA.width - 1,
|
|
556
|
+
height: UWHD.height - 1
|
|
557
|
+
})).toBe('uw-uxga');
|
|
558
|
+
expect((0, _resolution.getScreenType)({
|
|
559
|
+
width: UWUXGA.width - 1,
|
|
560
|
+
height: UWHD.height + 1
|
|
561
|
+
})).toBe('uw-uxga');
|
|
453
562
|
expect((0, _resolution.getScreenType)({
|
|
454
563
|
width: UWUXGA.width - 1,
|
|
455
564
|
height: UWUXGA.height - 1
|
|
@@ -481,6 +590,14 @@ describe('Resolution Specs', function () {
|
|
|
481
590
|
})).toBe('qhd');
|
|
482
591
|
|
|
483
592
|
// WQHD
|
|
593
|
+
expect((0, _resolution.getScreenType)({
|
|
594
|
+
width: UWUXGA.width + 1,
|
|
595
|
+
height: UWHD.height - 1
|
|
596
|
+
})).toBe('wqhd');
|
|
597
|
+
expect((0, _resolution.getScreenType)({
|
|
598
|
+
width: UWUXGA.width + 1,
|
|
599
|
+
height: UWHD.height + 1
|
|
600
|
+
})).toBe('wqhd');
|
|
484
601
|
expect((0, _resolution.getScreenType)({
|
|
485
602
|
width: UWUXGA.width + 1,
|
|
486
603
|
height: UWUXGA.height - 1
|
|
@@ -528,11 +645,17 @@ describe('Resolution Specs', function () {
|
|
|
528
645
|
height: UHD.height - 1
|
|
529
646
|
})).toBe('uhd');
|
|
530
647
|
|
|
531
|
-
//
|
|
648
|
+
// WUHD
|
|
532
649
|
expect((0, _resolution.getScreenType)({
|
|
533
650
|
width: UHD.width + 1,
|
|
534
651
|
height: UHD.height - 1
|
|
535
|
-
})).toBe('
|
|
652
|
+
})).toBe('wuhd');
|
|
653
|
+
expect((0, _resolution.getScreenType)({
|
|
654
|
+
width: WUHD.width - 1,
|
|
655
|
+
height: WUHD.height - 1
|
|
656
|
+
})).toBe('wuhd');
|
|
657
|
+
|
|
658
|
+
// UHD2
|
|
536
659
|
expect((0, _resolution.getScreenType)({
|
|
537
660
|
width: UHD.width - 1,
|
|
538
661
|
height: UHD.height + 1
|
|
@@ -541,12 +664,56 @@ describe('Resolution Specs', function () {
|
|
|
541
664
|
width: UHD.width + 1,
|
|
542
665
|
height: UHD.height + 1
|
|
543
666
|
})).toBe('uhd2');
|
|
667
|
+
expect((0, _resolution.getScreenType)({
|
|
668
|
+
width: WUHD.width + 1,
|
|
669
|
+
height: WUHD.height - 1
|
|
670
|
+
})).toBe('uhd2');
|
|
671
|
+
expect((0, _resolution.getScreenType)({
|
|
672
|
+
width: WUHD.width - 1,
|
|
673
|
+
height: WUHD.height + 1
|
|
674
|
+
})).toBe('uhd2');
|
|
675
|
+
expect((0, _resolution.getScreenType)({
|
|
676
|
+
width: WUHD.width + 1,
|
|
677
|
+
height: WUHD.height + 1
|
|
678
|
+
})).toBe('uhd2');
|
|
679
|
+
expect((0, _resolution.getScreenType)({
|
|
680
|
+
width: WUHD.width - 1,
|
|
681
|
+
height: UHD2.height - 1
|
|
682
|
+
})).toBe('uhd2');
|
|
683
|
+
expect((0, _resolution.getScreenType)({
|
|
684
|
+
width: WUHD.width + 1,
|
|
685
|
+
height: UHD2.height - 1
|
|
686
|
+
})).toBe('uhd2');
|
|
687
|
+
expect((0, _resolution.getScreenType)({
|
|
688
|
+
width: UHD2.width - 1,
|
|
689
|
+
height: WUHD.height - 1
|
|
690
|
+
})).toBe('uhd2');
|
|
691
|
+
expect((0, _resolution.getScreenType)({
|
|
692
|
+
width: UHD2.width - 1,
|
|
693
|
+
height: WUHD.height + 1
|
|
694
|
+
})).toBe('uhd2');
|
|
544
695
|
expect((0, _resolution.getScreenType)({
|
|
545
696
|
width: UHD2.width - 1,
|
|
546
697
|
height: UHD2.height - 1
|
|
547
698
|
})).toBe('uhd2');
|
|
548
699
|
|
|
549
700
|
// if width or height of screen is bigger than the biggest screen type, select the biggest screen type
|
|
701
|
+
expect((0, _resolution.getScreenType)({
|
|
702
|
+
width: WUHD.width - 1,
|
|
703
|
+
height: UHD2.height + 1
|
|
704
|
+
})).toBe('uhd2');
|
|
705
|
+
expect((0, _resolution.getScreenType)({
|
|
706
|
+
width: WUHD.width + 1,
|
|
707
|
+
height: UHD2.height + 1
|
|
708
|
+
})).toBe('uhd2');
|
|
709
|
+
expect((0, _resolution.getScreenType)({
|
|
710
|
+
width: UHD2.width + 1,
|
|
711
|
+
height: WUHD.height - 1
|
|
712
|
+
})).toBe('uhd2');
|
|
713
|
+
expect((0, _resolution.getScreenType)({
|
|
714
|
+
width: UHD2.width + 1,
|
|
715
|
+
height: WUHD.height + 1
|
|
716
|
+
})).toBe('uhd2');
|
|
550
717
|
expect((0, _resolution.getScreenType)({
|
|
551
718
|
width: UHD2.width + 1,
|
|
552
719
|
height: UHD2.height - 1
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports["default"] = exports.ScrollAnimator = void 0;
|
|
7
7
|
var _util = require("@enact/core/util");
|
|
8
8
|
var _clamp = _interopRequireDefault(require("ramda/src/clamp"));
|
|
9
|
+
var _utilAnimation = _interopRequireDefault(require("./utilAnimation"));
|
|
9
10
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
10
11
|
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
11
12
|
function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
|
|
@@ -28,6 +29,14 @@ var
|
|
|
28
29
|
curTime--;
|
|
29
30
|
return (target - source) * (curTime * curTime * curTime * curTime * curTime + 1) + source;
|
|
30
31
|
},
|
|
32
|
+
'ease-out-cubic': function easeOutCubic(source, target, duration, curTime, keyPressed) {
|
|
33
|
+
if (keyPressed) {
|
|
34
|
+
curTime /= duration;
|
|
35
|
+
return (target - source) * curTime + source;
|
|
36
|
+
}
|
|
37
|
+
curTime /= duration;
|
|
38
|
+
return (target - source) * (0, _utilAnimation["default"])(0.1, 0.6, 0.15, 1).cubicBezier(curTime) + source;
|
|
39
|
+
},
|
|
31
40
|
'ease-in-out': function easeInOut(source, target, duration, curTime) {
|
|
32
41
|
curTime /= duration / 2;
|
|
33
42
|
if (curTime < 1) {
|
|
@@ -59,7 +68,7 @@ var
|
|
|
59
68
|
var ScrollAnimator = exports.ScrollAnimator = /*#__PURE__*/function () {
|
|
60
69
|
/**
|
|
61
70
|
* @param {String|null} type - Timing function type for list scroll animation. Must be one of
|
|
62
|
-
* `'linear'`, `'ease-in'`, `'ease-out'`, or `'ease-in-out'`, or null. If `null`, defaults to
|
|
71
|
+
* `'linear'`, `'ease-in'`, `'ease-out'`, `'ease-out-cubic'`, or `'ease-in-out'`, or null. If `null`, defaults to
|
|
63
72
|
* `'ease-out'`.
|
|
64
73
|
* @constructor
|
|
65
74
|
* @memberof ui/useScroll.ScrollAnimator
|
|
@@ -67,7 +76,7 @@ var ScrollAnimator = exports.ScrollAnimator = /*#__PURE__*/function () {
|
|
|
67
76
|
function ScrollAnimator(type) {
|
|
68
77
|
_classCallCheck(this, ScrollAnimator);
|
|
69
78
|
this.rAFId = null;
|
|
70
|
-
this.type = 'ease-out';
|
|
79
|
+
this.type = 'ease-out-cubic';
|
|
71
80
|
this.timingFunction = timingFunctions[type || this.type];
|
|
72
81
|
}
|
|
73
82
|
return _createClass(ScrollAnimator, [{
|
package/useScroll/useScroll.js
CHANGED
|
@@ -53,6 +53,7 @@ function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, 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,
|
|
56
|
+
minAnimationDuration: 100,
|
|
56
57
|
epsilon: 1,
|
|
57
58
|
flickConfig: {
|
|
58
59
|
maxDuration: null
|
|
@@ -72,6 +73,7 @@ var constants = exports.constants = {
|
|
|
72
73
|
scrollWheelPageMultiplierForMaxPixel: 0.2 // The ratio of the maximum distance scrolled by wheel to the size of the viewport.
|
|
73
74
|
},
|
|
74
75
|
animationDuration = constants.animationDuration,
|
|
76
|
+
minAnimationDuration = constants.minAnimationDuration,
|
|
75
77
|
epsilon = constants.epsilon,
|
|
76
78
|
flickConfig = constants.flickConfig,
|
|
77
79
|
isPageDown = constants.isPageDown,
|
|
@@ -837,6 +839,7 @@ var useScrollBase = exports.useScrollBase = function useScrollBase(props) {
|
|
|
837
839
|
// scrollMode 'native' ]]
|
|
838
840
|
|
|
839
841
|
function onKeyDown(ev) {
|
|
842
|
+
mutableRef.current.keyPressed = ev.repeat;
|
|
840
843
|
if (scrollMode === 'translate') {
|
|
841
844
|
if (props.onKeyDown) {
|
|
842
845
|
(0, _handle.forward)('onKeyDown', ev, props);
|
|
@@ -849,6 +852,10 @@ var useScrollBase = exports.useScrollBase = function useScrollBase(props) {
|
|
|
849
852
|
(0, _handle.forward)('onKeyDown', ev, props);
|
|
850
853
|
}
|
|
851
854
|
}
|
|
855
|
+
function onKeyUp(ev) {
|
|
856
|
+
mutableRef.current.keyPressed = false;
|
|
857
|
+
(0, _handle.forward)('onKeyUp', ev, props);
|
|
858
|
+
}
|
|
852
859
|
function scrollToAccumulatedTarget(delta, vertical, overscrollEffect) {
|
|
853
860
|
if (!mutableRef.current.isScrollAnimationTargetAccumulated) {
|
|
854
861
|
mutableRef.current.accumulatedTargetX = mutableRef.current.scrollLeft;
|
|
@@ -1179,13 +1186,20 @@ var useScrollBase = exports.useScrollBase = function useScrollBase(props) {
|
|
|
1179
1186
|
targetX = animationInfo.targetX,
|
|
1180
1187
|
targetY = animationInfo.targetY,
|
|
1181
1188
|
duration = animationInfo.duration,
|
|
1182
|
-
bounds = getScrollBounds()
|
|
1183
|
-
|
|
1189
|
+
bounds = getScrollBounds(),
|
|
1190
|
+
scrollAnimationDuration = mutableRef.current.keyPressed ? minAnimationDuration : duration;
|
|
1191
|
+
var dynamicScrollDuration = function dynamicScrollDuration(target, source) {
|
|
1192
|
+
var customDuration = Math.max(minAnimationDuration, Math.abs(target - source));
|
|
1193
|
+
if (mutableRef.current.keyPressed) return minAnimationDuration;
|
|
1194
|
+
return animationDuration !== duration ? duration : Math.min(customDuration, duration);
|
|
1195
|
+
};
|
|
1196
|
+
if (curTime < scrollAnimationDuration) {
|
|
1184
1197
|
var toBeContinued = false,
|
|
1185
1198
|
curTargetX = sourceX,
|
|
1186
1199
|
curTargetY = sourceY;
|
|
1187
1200
|
if (canScrollHorizontally(bounds)) {
|
|
1188
|
-
|
|
1201
|
+
var scrollDuration = dynamicScrollDuration(sourceX, targetX);
|
|
1202
|
+
curTargetX = mutableRef.current.animator.timingFunction(sourceX, targetX, scrollDuration, curTime, mutableRef.current.keyPressed);
|
|
1189
1203
|
if (Math.abs(curTargetX - targetX) < epsilon) {
|
|
1190
1204
|
curTargetX = targetX;
|
|
1191
1205
|
} else {
|
|
@@ -1193,7 +1207,8 @@ var useScrollBase = exports.useScrollBase = function useScrollBase(props) {
|
|
|
1193
1207
|
}
|
|
1194
1208
|
}
|
|
1195
1209
|
if (canScrollVertically(bounds)) {
|
|
1196
|
-
|
|
1210
|
+
var _scrollDuration = dynamicScrollDuration(sourceY, targetY);
|
|
1211
|
+
curTargetY = mutableRef.current.animator.timingFunction(sourceY, targetY, _scrollDuration, curTime, mutableRef.current.keyPressed);
|
|
1197
1212
|
if (Math.abs(curTargetY - targetY) < epsilon) {
|
|
1198
1213
|
curTargetY = targetY;
|
|
1199
1214
|
} else {
|
|
@@ -1423,6 +1438,7 @@ var useScrollBase = exports.useScrollBase = function useScrollBase(props) {
|
|
|
1423
1438
|
function addEventListeners() {
|
|
1424
1439
|
(0, _utilEvent["default"])('wheel').addEventListener(scrollContainerRef, onWheel);
|
|
1425
1440
|
(0, _utilEvent["default"])('keydown').addEventListener(scrollContainerRef, onKeyDown);
|
|
1441
|
+
(0, _utilEvent["default"])('keyup').addEventListener(scrollContainerRef, onKeyUp);
|
|
1426
1442
|
(0, _utilEvent["default"])('mousedown').addEventListener(scrollContainerRef, onMouseDown);
|
|
1427
1443
|
|
|
1428
1444
|
// scrollMode 'native' [[
|
|
@@ -1445,6 +1461,7 @@ var useScrollBase = exports.useScrollBase = function useScrollBase(props) {
|
|
|
1445
1461
|
function removeEventListeners() {
|
|
1446
1462
|
(0, _utilEvent["default"])('wheel').removeEventListener(scrollContainerRef, onWheel);
|
|
1447
1463
|
(0, _utilEvent["default"])('keydown').removeEventListener(scrollContainerRef, onKeyDown);
|
|
1464
|
+
(0, _utilEvent["default"])('keyup').removeEventListener(scrollContainerRef, onKeyUp);
|
|
1448
1465
|
(0, _utilEvent["default"])('mousedown').removeEventListener(scrollContainerRef, onMouseDown);
|
|
1449
1466
|
|
|
1450
1467
|
// scrollMode 'native' [[
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.utilAnimation = exports["default"] = void 0;
|
|
7
|
+
/*
|
|
8
|
+
* Create a cubic-bezier easing function evaluator.
|
|
9
|
+
*/
|
|
10
|
+
var utilAnimation = exports.utilAnimation = function utilAnimation(x1, y1, x2, y2) {
|
|
11
|
+
var AX = 1 + 3 * x1 - 3 * x2;
|
|
12
|
+
var BX = 3 * x2 - 6 * x1;
|
|
13
|
+
var CX = 3 * x1;
|
|
14
|
+
var AY = 1 + 3 * y1 - 3 * y2;
|
|
15
|
+
var BY = 3 * y2 - 6 * y1;
|
|
16
|
+
var CY = 3 * y1;
|
|
17
|
+
function sampleCurveX(t) {
|
|
18
|
+
return ((AX * t + BX) * t + CX) * t;
|
|
19
|
+
}
|
|
20
|
+
function sampleCurveY(t) {
|
|
21
|
+
return ((AY * t + BY) * t + CY) * t;
|
|
22
|
+
}
|
|
23
|
+
function sampleCurveDerivativeX(t) {
|
|
24
|
+
return (3 * AX * t + 2 * BX) * t + CX;
|
|
25
|
+
}
|
|
26
|
+
function solveCurveX(x) {
|
|
27
|
+
var t0 = x;
|
|
28
|
+
var t1, t2;
|
|
29
|
+
for (var i = 0; i < 4; ++i) {
|
|
30
|
+
t2 = sampleCurveX(t0) - x;
|
|
31
|
+
if (Math.abs(t2) < 0.001) return t0;
|
|
32
|
+
t1 = sampleCurveDerivativeX(t0);
|
|
33
|
+
if (Math.abs(t1) < 1e-6) break;
|
|
34
|
+
t0 = t0 - t2 / t1;
|
|
35
|
+
}
|
|
36
|
+
return t0;
|
|
37
|
+
}
|
|
38
|
+
return {
|
|
39
|
+
cubicBezier: function cubicBezier(x) {
|
|
40
|
+
if (x === 0) return 0;
|
|
41
|
+
if (x === 1) return 1;
|
|
42
|
+
var t = solveCurveX(x);
|
|
43
|
+
return sampleCurveY(t);
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
var _default = exports["default"] = utilAnimation;
|