@enact/ui 4.9.0-alpha.1 → 4.9.0-alpha.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 +12 -0
- package/Marquee/MarqueeController.js +23 -284
- package/Marquee/index.d.ts +18 -18
- package/Marquee/useMarqueeController.js +273 -0
- package/Repeater/Repeater.js +7 -3
- package/Scroller/Scroller.js +20 -18
- package/Scroller/Scroller.module.css +3 -0
- package/Scroller/UiScroller.module.css +3 -0
- package/Slottable/tests/Slottable-specs.js +2 -4
- package/Toggleable/Toggleable.js +11 -5
- package/Touchable/Touchable.js +11 -6
- package/VirtualList/UiVirtualList.module.css +3 -0
- package/VirtualList/VirtualList.d.ts +13 -13
- package/VirtualList/VirtualList.js +25 -21
- package/VirtualList/VirtualList.module.css +3 -0
- package/package.json +5 -5
- package/resolution/tests/resolution-specs.js +503 -13
- package/useScroll/Scrollbar.js +18 -8
- package/useScroll/ScrollbarTrack.js +2 -4
|
@@ -25,30 +25,514 @@ describe('Resolution Specs', function () {
|
|
|
25
25
|
pxPerRem: 24,
|
|
26
26
|
width: 1920,
|
|
27
27
|
height: 1080,
|
|
28
|
-
aspectRatioName: 'hdtv'
|
|
29
|
-
base: true
|
|
28
|
+
aspectRatioName: 'hdtv'
|
|
30
29
|
}, {
|
|
31
30
|
name: 'uw-uxga',
|
|
32
31
|
pxPerRem: 24,
|
|
33
32
|
width: 2560,
|
|
34
33
|
height: 1080,
|
|
35
34
|
aspectRatioName: 'cinema'
|
|
35
|
+
}, {
|
|
36
|
+
name: 'qhd',
|
|
37
|
+
pxPerRem: 32,
|
|
38
|
+
width: 2560,
|
|
39
|
+
height: 1440,
|
|
40
|
+
aspectRatioName: 'hdtv'
|
|
41
|
+
}, {
|
|
42
|
+
name: 'wqhd',
|
|
43
|
+
pxPerRem: 32,
|
|
44
|
+
width: 3440,
|
|
45
|
+
height: 1440,
|
|
46
|
+
aspectRatioName: 'cinema'
|
|
36
47
|
}, {
|
|
37
48
|
name: 'uhd',
|
|
38
49
|
pxPerRem: 48,
|
|
39
50
|
width: 3840,
|
|
40
51
|
height: 2160,
|
|
52
|
+
aspectRatioName: 'hdtv',
|
|
53
|
+
base: true
|
|
54
|
+
}, {
|
|
55
|
+
name: 'uhd2',
|
|
56
|
+
pxPerRem: 96,
|
|
57
|
+
width: 7680,
|
|
58
|
+
height: 4320,
|
|
41
59
|
aspectRatioName: 'hdtv'
|
|
42
60
|
}];
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
61
|
+
var VGA = {
|
|
62
|
+
width: 640,
|
|
63
|
+
height: 480
|
|
64
|
+
};
|
|
65
|
+
var XGA = {
|
|
66
|
+
width: 1024,
|
|
67
|
+
height: 768
|
|
68
|
+
};
|
|
69
|
+
var HD = {
|
|
70
|
+
width: 1280,
|
|
71
|
+
height: 720
|
|
72
|
+
};
|
|
73
|
+
var FHD = {
|
|
74
|
+
width: 1920,
|
|
75
|
+
height: 1080
|
|
76
|
+
};
|
|
77
|
+
var UWUXGA = {
|
|
78
|
+
width: 2560,
|
|
79
|
+
height: 1080
|
|
80
|
+
};
|
|
81
|
+
var QHD = {
|
|
82
|
+
width: 2560,
|
|
83
|
+
height: 1440
|
|
84
|
+
};
|
|
85
|
+
var WQHD = {
|
|
86
|
+
width: 3440,
|
|
87
|
+
height: 1440
|
|
88
|
+
};
|
|
89
|
+
var UHD = {
|
|
90
|
+
width: 3840,
|
|
91
|
+
height: 2160
|
|
92
|
+
};
|
|
93
|
+
var UHD2 = {
|
|
94
|
+
width: 7680,
|
|
95
|
+
height: 4320
|
|
96
|
+
};
|
|
97
|
+
(0, _resolution.defineScreenTypes)(screenTypes);
|
|
98
|
+
describe('Matching Screen Types', function () {
|
|
99
|
+
test('should select screen type whose dimensions are same with the screen if exist', function () {
|
|
100
|
+
expect((0, _resolution.getScreenType)(VGA)).toBe('vga');
|
|
101
|
+
expect((0, _resolution.getScreenType)(XGA)).toBe('xga');
|
|
102
|
+
expect((0, _resolution.getScreenType)(HD)).toBe('hd');
|
|
103
|
+
expect((0, _resolution.getScreenType)(FHD)).toBe('fhd');
|
|
104
|
+
expect((0, _resolution.getScreenType)(UWUXGA)).toBe('uw-uxga');
|
|
105
|
+
expect((0, _resolution.getScreenType)(QHD)).toBe('qhd');
|
|
106
|
+
expect((0, _resolution.getScreenType)(WQHD)).toBe('wqhd');
|
|
107
|
+
expect((0, _resolution.getScreenType)(UHD)).toBe('uhd');
|
|
108
|
+
expect((0, _resolution.getScreenType)(UHD2)).toBe('uhd2');
|
|
109
|
+
});
|
|
110
|
+
test('should select screen type whose height and width are both smaller than or same with the screen if `matchSmallerScreenType` true', function () {
|
|
111
|
+
_resolution.config.matchSmallerScreenType = true;
|
|
112
|
+
|
|
113
|
+
// if width or height of screen is smaller than the smallest screen type, select the smallest screen type
|
|
114
|
+
expect((0, _resolution.getScreenType)({
|
|
115
|
+
width: VGA.width - 1,
|
|
116
|
+
height: VGA.height - 1
|
|
117
|
+
})).toBe('vga');
|
|
118
|
+
expect((0, _resolution.getScreenType)({
|
|
119
|
+
width: VGA.width + 1,
|
|
120
|
+
height: VGA.height - 1
|
|
121
|
+
})).toBe('vga');
|
|
122
|
+
expect((0, _resolution.getScreenType)({
|
|
123
|
+
width: VGA.width - 1,
|
|
124
|
+
height: VGA.height + 1
|
|
125
|
+
})).toBe('vga');
|
|
126
|
+
|
|
127
|
+
// VGA
|
|
128
|
+
expect((0, _resolution.getScreenType)({
|
|
129
|
+
width: VGA.width + 1,
|
|
130
|
+
height: VGA.height + 1
|
|
131
|
+
})).toBe('vga');
|
|
132
|
+
expect((0, _resolution.getScreenType)({
|
|
133
|
+
width: XGA.width - 1,
|
|
134
|
+
height: XGA.height - 1
|
|
135
|
+
})).toBe('vga');
|
|
136
|
+
expect((0, _resolution.getScreenType)({
|
|
137
|
+
width: XGA.width + 1,
|
|
138
|
+
height: XGA.height - 1
|
|
139
|
+
})).toBe('vga');
|
|
140
|
+
expect((0, _resolution.getScreenType)({
|
|
141
|
+
width: XGA.width - 1,
|
|
142
|
+
height: XGA.height + 1
|
|
143
|
+
})).toBe('vga');
|
|
144
|
+
expect((0, _resolution.getScreenType)({
|
|
145
|
+
width: HD.width - 1,
|
|
146
|
+
height: HD.height - 1
|
|
147
|
+
})).toBe('vga');
|
|
148
|
+
expect((0, _resolution.getScreenType)({
|
|
149
|
+
width: HD.width + 1,
|
|
150
|
+
height: HD.height - 1
|
|
151
|
+
})).toBe('vga');
|
|
152
|
+
expect((0, _resolution.getScreenType)({
|
|
153
|
+
width: HD.width - 1,
|
|
154
|
+
height: HD.height + 1
|
|
155
|
+
})).toBe('vga');
|
|
156
|
+
expect((0, _resolution.getScreenType)({
|
|
157
|
+
width: XGA.width,
|
|
158
|
+
height: HD.height
|
|
159
|
+
})).toBe('vga');
|
|
160
|
+
expect((0, _resolution.getScreenType)({
|
|
161
|
+
width: XGA.width - 1,
|
|
162
|
+
height: HD.height - 1
|
|
163
|
+
})).toBe('vga');
|
|
164
|
+
expect((0, _resolution.getScreenType)({
|
|
165
|
+
width: XGA.width + 1,
|
|
166
|
+
height: HD.height - 1
|
|
167
|
+
})).toBe('vga');
|
|
168
|
+
expect((0, _resolution.getScreenType)({
|
|
169
|
+
width: XGA.width - 1,
|
|
170
|
+
height: HD.height + 1
|
|
171
|
+
})).toBe('vga');
|
|
172
|
+
expect((0, _resolution.getScreenType)({
|
|
173
|
+
width: XGA.width + 1,
|
|
174
|
+
height: HD.height + 1
|
|
175
|
+
})).toBe('vga');
|
|
176
|
+
expect((0, _resolution.getScreenType)({
|
|
177
|
+
width: HD.width - 1,
|
|
178
|
+
height: XGA.height - 1
|
|
179
|
+
})).toBe('vga');
|
|
180
|
+
|
|
181
|
+
// XGA
|
|
182
|
+
expect((0, _resolution.getScreenType)({
|
|
183
|
+
width: XGA.width + 1,
|
|
184
|
+
height: XGA.height + 1
|
|
185
|
+
})).toBe('xga');
|
|
186
|
+
expect((0, _resolution.getScreenType)({
|
|
187
|
+
width: HD.width - 1,
|
|
188
|
+
height: XGA.height + 1
|
|
189
|
+
})).toBe('xga');
|
|
190
|
+
|
|
191
|
+
// HD
|
|
192
|
+
expect((0, _resolution.getScreenType)({
|
|
193
|
+
width: HD.width + 1,
|
|
194
|
+
height: HD.height + 1
|
|
195
|
+
})).toBe('hd');
|
|
196
|
+
expect((0, _resolution.getScreenType)({
|
|
197
|
+
width: HD.width,
|
|
198
|
+
height: XGA.height
|
|
199
|
+
})).toBe('hd');
|
|
200
|
+
expect((0, _resolution.getScreenType)({
|
|
201
|
+
width: HD.width + 1,
|
|
202
|
+
height: XGA.height - 1
|
|
203
|
+
})).toBe('hd');
|
|
204
|
+
expect((0, _resolution.getScreenType)({
|
|
205
|
+
width: HD.width + 1,
|
|
206
|
+
height: XGA.height + 1
|
|
207
|
+
})).toBe('hd');
|
|
208
|
+
expect((0, _resolution.getScreenType)({
|
|
209
|
+
width: FHD.width - 1,
|
|
210
|
+
height: FHD.height - 1
|
|
211
|
+
})).toBe('hd');
|
|
212
|
+
expect((0, _resolution.getScreenType)({
|
|
213
|
+
width: FHD.width + 1,
|
|
214
|
+
height: FHD.height - 1
|
|
215
|
+
})).toBe('hd');
|
|
216
|
+
expect((0, _resolution.getScreenType)({
|
|
217
|
+
width: FHD.width - 1,
|
|
218
|
+
height: FHD.height + 1
|
|
219
|
+
})).toBe('hd');
|
|
220
|
+
expect((0, _resolution.getScreenType)({
|
|
221
|
+
width: UWUXGA.width - 1,
|
|
222
|
+
height: UWUXGA.height - 1
|
|
223
|
+
})).toBe('hd'); // {height: FHD.height - 1, width: UWUXGA.width - 1}
|
|
224
|
+
expect((0, _resolution.getScreenType)({
|
|
225
|
+
width: UWUXGA.width + 1,
|
|
226
|
+
height: UWUXGA.height - 1
|
|
227
|
+
})).toBe('hd'); // {height: FHD.height - 1, width: UWUXGA.width + 1}
|
|
228
|
+
|
|
229
|
+
// FHD
|
|
230
|
+
expect((0, _resolution.getScreenType)({
|
|
231
|
+
width: FHD.width + 1,
|
|
232
|
+
height: FHD.height + 1
|
|
233
|
+
})).toBe('fhd');
|
|
234
|
+
expect((0, _resolution.getScreenType)({
|
|
235
|
+
width: UWUXGA.width - 1,
|
|
236
|
+
height: UWUXGA.height + 1
|
|
237
|
+
})).toBe('fhd'); // {height: FHD.height + 1, width: UWUXGA.width - 1}
|
|
238
|
+
|
|
239
|
+
expect((0, _resolution.getScreenType)({
|
|
240
|
+
width: QHD.width - 1,
|
|
241
|
+
height: QHD.height - 1
|
|
242
|
+
})).toBe('fhd'); // {height: QHD.height - 1, width: UWUXGA.width - 1}
|
|
243
|
+
expect((0, _resolution.getScreenType)({
|
|
244
|
+
width: QHD.width - 1,
|
|
245
|
+
height: QHD.height + 1
|
|
246
|
+
})).toBe('fhd'); // {height: QHD.height + 1, width: UWUXGA.width - 1}
|
|
247
|
+
|
|
248
|
+
// UWUXGA
|
|
249
|
+
expect((0, _resolution.getScreenType)({
|
|
250
|
+
width: UWUXGA.width + 1,
|
|
251
|
+
height: UWUXGA.height + 1
|
|
252
|
+
})).toBe('uw-uxga'); // {height: FHD.height + 1, width: UWUXGA.width + 1}
|
|
253
|
+
|
|
254
|
+
expect((0, _resolution.getScreenType)({
|
|
255
|
+
width: QHD.width + 1,
|
|
256
|
+
height: QHD.height - 1
|
|
257
|
+
})).toBe('uw-uxga'); // {height: QHD.height - 1, width: UWUXGA.width + 1}
|
|
258
|
+
|
|
259
|
+
expect((0, _resolution.getScreenType)({
|
|
260
|
+
width: WQHD.width - 1,
|
|
261
|
+
height: WQHD.height - 1
|
|
262
|
+
})).toBe('uw-uxga'); // {height: QHD.height - 1, width: WQHD.width - 1}
|
|
263
|
+
expect((0, _resolution.getScreenType)({
|
|
264
|
+
width: WQHD.width + 1,
|
|
265
|
+
height: WQHD.height - 1
|
|
266
|
+
})).toBe('uw-uxga'); // {height: QHD.height - 1, width: WQHD.width + 1}
|
|
267
|
+
|
|
268
|
+
// QHD
|
|
269
|
+
expect((0, _resolution.getScreenType)({
|
|
270
|
+
width: QHD.width + 1,
|
|
271
|
+
height: QHD.height + 1
|
|
272
|
+
})).toBe('qhd'); // {height: QHD.height + 1, width: UWUXGA.width + 1}
|
|
273
|
+
|
|
274
|
+
expect((0, _resolution.getScreenType)({
|
|
275
|
+
width: WQHD.width - 1,
|
|
276
|
+
height: WQHD.height + 1
|
|
277
|
+
})).toBe('qhd'); // {height: QHD.height + 1, width: WQHD.width - 1}
|
|
278
|
+
|
|
279
|
+
// WQHD
|
|
280
|
+
expect((0, _resolution.getScreenType)({
|
|
281
|
+
width: WQHD.width + 1,
|
|
282
|
+
height: WQHD.height + 1
|
|
283
|
+
})).toBe('wqhd'); // {height: QHD.height + 1, width: WQHD.width + 1}
|
|
284
|
+
|
|
285
|
+
expect((0, _resolution.getScreenType)({
|
|
286
|
+
width: UHD.width - 1,
|
|
287
|
+
height: UHD.height - 1
|
|
288
|
+
})).toBe('wqhd');
|
|
289
|
+
expect((0, _resolution.getScreenType)({
|
|
290
|
+
width: UHD.width + 1,
|
|
291
|
+
height: UHD.height - 1
|
|
292
|
+
})).toBe('wqhd');
|
|
293
|
+
expect((0, _resolution.getScreenType)({
|
|
294
|
+
width: UHD.width - 1,
|
|
295
|
+
height: UHD.height + 1
|
|
296
|
+
})).toBe('wqhd');
|
|
297
|
+
|
|
298
|
+
// UHD
|
|
299
|
+
expect((0, _resolution.getScreenType)({
|
|
300
|
+
width: UHD.width + 1,
|
|
301
|
+
height: UHD.height + 1
|
|
302
|
+
})).toBe('uhd');
|
|
303
|
+
expect((0, _resolution.getScreenType)({
|
|
304
|
+
width: UHD2.width - 1,
|
|
305
|
+
height: UHD2.height - 1
|
|
306
|
+
})).toBe('uhd');
|
|
307
|
+
expect((0, _resolution.getScreenType)({
|
|
308
|
+
width: UHD2.width + 1,
|
|
309
|
+
height: UHD2.height - 1
|
|
310
|
+
})).toBe('uhd');
|
|
311
|
+
expect((0, _resolution.getScreenType)({
|
|
312
|
+
width: UHD2.width - 1,
|
|
313
|
+
height: UHD2.height + 1
|
|
314
|
+
})).toBe('uhd');
|
|
315
|
+
|
|
316
|
+
// UHD2
|
|
317
|
+
expect((0, _resolution.getScreenType)({
|
|
318
|
+
width: UHD2.width + 1,
|
|
319
|
+
height: UHD2.height + 1
|
|
320
|
+
})).toBe('uhd2');
|
|
321
|
+
});
|
|
322
|
+
test('should select screen type whose height and width are both bigger than or same with the screen if `matchSmallerScreenType` false', function () {
|
|
323
|
+
_resolution.config.matchSmallerScreenType = false;
|
|
324
|
+
|
|
325
|
+
// VGA
|
|
326
|
+
expect((0, _resolution.getScreenType)({
|
|
327
|
+
width: VGA.width - 1,
|
|
328
|
+
height: VGA.height - 1
|
|
329
|
+
})).toBe('vga');
|
|
330
|
+
|
|
331
|
+
// XGA
|
|
332
|
+
expect((0, _resolution.getScreenType)({
|
|
333
|
+
width: VGA.width + 1,
|
|
334
|
+
height: VGA.height - 1
|
|
335
|
+
})).toBe('xga');
|
|
336
|
+
expect((0, _resolution.getScreenType)({
|
|
337
|
+
width: VGA.width - 1,
|
|
338
|
+
height: VGA.height + 1
|
|
339
|
+
})).toBe('xga');
|
|
340
|
+
expect((0, _resolution.getScreenType)({
|
|
341
|
+
width: VGA.width + 1,
|
|
342
|
+
height: VGA.height + 1
|
|
343
|
+
})).toBe('xga');
|
|
344
|
+
expect((0, _resolution.getScreenType)({
|
|
345
|
+
width: XGA.width - 1,
|
|
346
|
+
height: XGA.height - 1
|
|
347
|
+
})).toBe('xga');
|
|
348
|
+
expect((0, _resolution.getScreenType)({
|
|
349
|
+
width: XGA.width,
|
|
350
|
+
height: HD.height
|
|
351
|
+
})).toBe('xga');
|
|
352
|
+
expect((0, _resolution.getScreenType)({
|
|
353
|
+
width: XGA.width - 1,
|
|
354
|
+
height: HD.height - 1
|
|
355
|
+
})).toBe('xga');
|
|
356
|
+
expect((0, _resolution.getScreenType)({
|
|
357
|
+
width: XGA.width - 1,
|
|
358
|
+
height: HD.height + 1
|
|
359
|
+
})).toBe('xga');
|
|
360
|
+
|
|
361
|
+
// HD
|
|
362
|
+
expect((0, _resolution.getScreenType)({
|
|
363
|
+
width: XGA.width + 1,
|
|
364
|
+
height: HD.height - 1
|
|
365
|
+
})).toBe('hd');
|
|
366
|
+
expect((0, _resolution.getScreenType)({
|
|
367
|
+
width: HD.width - 1,
|
|
368
|
+
height: HD.height - 1
|
|
369
|
+
})).toBe('hd');
|
|
370
|
+
|
|
371
|
+
// FHD
|
|
372
|
+
expect((0, _resolution.getScreenType)({
|
|
373
|
+
width: XGA.width + 1,
|
|
374
|
+
height: XGA.height - 1
|
|
375
|
+
})).toBe('fhd');
|
|
376
|
+
expect((0, _resolution.getScreenType)({
|
|
377
|
+
width: XGA.width - 1,
|
|
378
|
+
height: XGA.height + 1
|
|
379
|
+
})).toBe('fhd');
|
|
380
|
+
expect((0, _resolution.getScreenType)({
|
|
381
|
+
width: XGA.width + 1,
|
|
382
|
+
height: XGA.height + 1
|
|
383
|
+
})).toBe('fhd');
|
|
384
|
+
expect((0, _resolution.getScreenType)({
|
|
385
|
+
width: HD.width,
|
|
386
|
+
height: XGA.height
|
|
387
|
+
})).toBe('fhd');
|
|
388
|
+
expect((0, _resolution.getScreenType)({
|
|
389
|
+
width: HD.width - 1,
|
|
390
|
+
height: XGA.height - 1
|
|
391
|
+
})).toBe('fhd');
|
|
392
|
+
expect((0, _resolution.getScreenType)({
|
|
393
|
+
width: HD.width + 1,
|
|
394
|
+
height: XGA.height - 1
|
|
395
|
+
})).toBe('fhd');
|
|
396
|
+
expect((0, _resolution.getScreenType)({
|
|
397
|
+
width: HD.width - 1,
|
|
398
|
+
height: XGA.height + 1
|
|
399
|
+
})).toBe('fhd');
|
|
400
|
+
expect((0, _resolution.getScreenType)({
|
|
401
|
+
width: HD.width + 1,
|
|
402
|
+
height: XGA.height + 1
|
|
403
|
+
})).toBe('fhd');
|
|
404
|
+
expect((0, _resolution.getScreenType)({
|
|
405
|
+
width: XGA.width + 1,
|
|
406
|
+
height: HD.height + 1
|
|
407
|
+
})).toBe('fhd');
|
|
408
|
+
expect((0, _resolution.getScreenType)({
|
|
409
|
+
width: HD.width + 1,
|
|
410
|
+
height: HD.height - 1
|
|
411
|
+
})).toBe('fhd');
|
|
412
|
+
expect((0, _resolution.getScreenType)({
|
|
413
|
+
width: HD.width - 1,
|
|
414
|
+
height: HD.height + 1
|
|
415
|
+
})).toBe('fhd');
|
|
416
|
+
expect((0, _resolution.getScreenType)({
|
|
417
|
+
width: HD.width + 1,
|
|
418
|
+
height: HD.height + 1
|
|
419
|
+
})).toBe('fhd');
|
|
420
|
+
expect((0, _resolution.getScreenType)({
|
|
421
|
+
width: FHD.width - 1,
|
|
422
|
+
height: FHD.height - 1
|
|
423
|
+
})).toBe('fhd');
|
|
424
|
+
|
|
425
|
+
// UWUXGA
|
|
426
|
+
expect((0, _resolution.getScreenType)({
|
|
427
|
+
width: UWUXGA.width - 1,
|
|
428
|
+
height: UWUXGA.height - 1
|
|
429
|
+
})).toBe('uw-uxga'); // {height: FHD.height - 1, width: UWUXGA.width - 1}
|
|
430
|
+
|
|
431
|
+
expect((0, _resolution.getScreenType)({
|
|
432
|
+
width: FHD.width + 1,
|
|
433
|
+
height: FHD.height - 1
|
|
434
|
+
})).toBe('uw-uxga');
|
|
435
|
+
|
|
436
|
+
// QHD
|
|
437
|
+
expect((0, _resolution.getScreenType)({
|
|
438
|
+
width: UWUXGA.width - 1,
|
|
439
|
+
height: UWUXGA.height + 1
|
|
440
|
+
})).toBe('qhd'); // {height: FHD.height + 1, width: UWUXGA.width - 1}
|
|
441
|
+
|
|
442
|
+
expect((0, _resolution.getScreenType)({
|
|
443
|
+
width: QHD.width - 1,
|
|
444
|
+
height: QHD.height - 1
|
|
445
|
+
})).toBe('qhd'); // {height: QHD.height - 1, width: UWUXGA.width - 1}
|
|
446
|
+
|
|
447
|
+
expect((0, _resolution.getScreenType)({
|
|
448
|
+
width: FHD.width - 1,
|
|
449
|
+
height: FHD.height + 1
|
|
450
|
+
})).toBe('qhd');
|
|
451
|
+
expect((0, _resolution.getScreenType)({
|
|
452
|
+
width: FHD.width + 1,
|
|
453
|
+
height: FHD.height + 1
|
|
454
|
+
})).toBe('qhd');
|
|
455
|
+
|
|
456
|
+
// WQHD
|
|
457
|
+
expect((0, _resolution.getScreenType)({
|
|
458
|
+
width: UWUXGA.width + 1,
|
|
459
|
+
height: UWUXGA.height - 1
|
|
460
|
+
})).toBe('wqhd'); // {height: FHD.height - 1, width: UWUXGA.width + 1}
|
|
461
|
+
expect((0, _resolution.getScreenType)({
|
|
462
|
+
width: UWUXGA.width + 1,
|
|
463
|
+
height: UWUXGA.height + 1
|
|
464
|
+
})).toBe('wqhd'); // {height: FHD.height + 1, width: UWUXGA.width + 1}
|
|
465
|
+
|
|
466
|
+
expect((0, _resolution.getScreenType)({
|
|
467
|
+
width: QHD.width + 1,
|
|
468
|
+
height: QHD.height - 1
|
|
469
|
+
})).toBe('wqhd'); // {height: QHD.height - 1, width: UWUXGA.width + 1}
|
|
470
|
+
|
|
471
|
+
expect((0, _resolution.getScreenType)({
|
|
472
|
+
width: WQHD.width - 1,
|
|
473
|
+
height: WQHD.height - 1
|
|
474
|
+
})).toBe('wqhd'); // {height: QHD.height - 1, width: WQHD.width - 1}
|
|
475
|
+
|
|
476
|
+
// UHD
|
|
477
|
+
expect((0, _resolution.getScreenType)({
|
|
478
|
+
width: QHD.width - 1,
|
|
479
|
+
height: QHD.height + 1
|
|
480
|
+
})).toBe('uhd'); // {height: QHD.height + 1, width: UWUXGA.width - 1}
|
|
481
|
+
expect((0, _resolution.getScreenType)({
|
|
482
|
+
width: QHD.width + 1,
|
|
483
|
+
height: QHD.height + 1
|
|
484
|
+
})).toBe('uhd'); // {height: QHD.height + 1, width: UWUXGA.width + 1}
|
|
485
|
+
|
|
486
|
+
expect((0, _resolution.getScreenType)({
|
|
487
|
+
width: WQHD.width + 1,
|
|
488
|
+
height: WQHD.height - 1
|
|
489
|
+
})).toBe('uhd'); // {height: QHD.height - 1, width: WQHD.width + 1}
|
|
490
|
+
expect((0, _resolution.getScreenType)({
|
|
491
|
+
width: WQHD.width - 1,
|
|
492
|
+
height: WQHD.height + 1
|
|
493
|
+
})).toBe('uhd'); // {height: QHD.height + 1, width: WQHD.width - 1}
|
|
494
|
+
expect((0, _resolution.getScreenType)({
|
|
495
|
+
width: WQHD.width + 1,
|
|
496
|
+
height: WQHD.height + 1
|
|
497
|
+
})).toBe('uhd'); // {height: QHD.height + 1, width: WQHD.width + 1}
|
|
498
|
+
|
|
499
|
+
expect((0, _resolution.getScreenType)({
|
|
500
|
+
width: UHD.width - 1,
|
|
501
|
+
height: UHD.height - 1
|
|
502
|
+
})).toBe('uhd');
|
|
503
|
+
|
|
504
|
+
// UHD2
|
|
505
|
+
expect((0, _resolution.getScreenType)({
|
|
506
|
+
width: UHD.width + 1,
|
|
507
|
+
height: UHD.height - 1
|
|
508
|
+
})).toBe('uhd2');
|
|
509
|
+
expect((0, _resolution.getScreenType)({
|
|
510
|
+
width: UHD.width - 1,
|
|
511
|
+
height: UHD.height + 1
|
|
512
|
+
})).toBe('uhd2');
|
|
513
|
+
expect((0, _resolution.getScreenType)({
|
|
514
|
+
width: UHD.width + 1,
|
|
515
|
+
height: UHD.height + 1
|
|
516
|
+
})).toBe('uhd2');
|
|
517
|
+
expect((0, _resolution.getScreenType)({
|
|
518
|
+
width: UHD2.width - 1,
|
|
519
|
+
height: UHD2.height - 1
|
|
520
|
+
})).toBe('uhd2');
|
|
521
|
+
|
|
522
|
+
// if width or height of screen is bigger than the biggest screen type, select the biggest screen type
|
|
523
|
+
expect((0, _resolution.getScreenType)({
|
|
524
|
+
width: UHD2.width + 1,
|
|
525
|
+
height: UHD2.height - 1
|
|
526
|
+
})).toBe('uhd2');
|
|
527
|
+
expect((0, _resolution.getScreenType)({
|
|
528
|
+
width: UHD2.width - 1,
|
|
529
|
+
height: UHD2.height + 1
|
|
530
|
+
})).toBe('uhd2');
|
|
531
|
+
expect((0, _resolution.getScreenType)({
|
|
532
|
+
width: UHD2.width + 1,
|
|
533
|
+
height: UHD2.height + 1
|
|
534
|
+
})).toBe('uhd2');
|
|
535
|
+
});
|
|
52
536
|
});
|
|
53
537
|
test('should detect portrait orientation', function () {
|
|
54
538
|
var fhdPortrait = {
|
|
@@ -61,17 +545,23 @@ describe('Resolution Specs', function () {
|
|
|
61
545
|
expect(actual).toBe(expected);
|
|
62
546
|
});
|
|
63
547
|
test('should calculate the base font size for the given screen type', function () {
|
|
548
|
+
var expectedUHD = '48px';
|
|
549
|
+
var actualUHD = (0, _resolution.calculateFontSize)('uhd');
|
|
550
|
+
var expectedQHD = '32px';
|
|
551
|
+
var actualQHD = (0, _resolution.calculateFontSize)('qhd');
|
|
64
552
|
var expectedFHD = '24px';
|
|
65
553
|
var actualFHD = (0, _resolution.calculateFontSize)('fhd');
|
|
66
554
|
var expectedHD = '16px';
|
|
67
555
|
var actualHD = (0, _resolution.calculateFontSize)('hd');
|
|
556
|
+
expect(actualUHD).toBe(expectedUHD);
|
|
557
|
+
expect(actualQHD).toBe(expectedQHD);
|
|
68
558
|
expect(actualFHD).toBe(expectedFHD);
|
|
69
559
|
expect(actualHD).toBe(expectedHD);
|
|
70
560
|
});
|
|
71
561
|
test('should scale pixel measurements for the current screen', function () {
|
|
72
|
-
var expectedFHD = 24 /
|
|
562
|
+
var expectedFHD = 24 / 6;
|
|
73
563
|
var actualFHD = (0, _resolution.scale)(24);
|
|
74
|
-
var expectedHD = 16 /
|
|
564
|
+
var expectedHD = 16 / 6;
|
|
75
565
|
var actualHD = (0, _resolution.scale)(16);
|
|
76
566
|
expect(actualFHD).toBe(expectedFHD);
|
|
77
567
|
expect(actualHD).toBe(expectedHD);
|
package/useScroll/Scrollbar.js
CHANGED
|
@@ -19,7 +19,8 @@ var _resolution = _interopRequireDefault(require("../resolution"));
|
|
|
19
19
|
var _ScrollbarTrack = _interopRequireDefault(require("./ScrollbarTrack"));
|
|
20
20
|
var _ScrollbarModule = _interopRequireDefault(require("./Scrollbar.module.css"));
|
|
21
21
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
22
|
-
var _excluded = ["className", "clientSize", "corner", "css", "minThumbSize", "scrollbarHandle", "vertical"]
|
|
22
|
+
var _excluded = ["className", "clientSize", "corner", "css", "minThumbSize", "scrollbarHandle", "vertical"],
|
|
23
|
+
_excluded2 = ["corner", "css", "minThumbSize", "vertical"];
|
|
23
24
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
24
25
|
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; }
|
|
25
26
|
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; }
|
|
@@ -134,7 +135,22 @@ var useScrollbar = exports.useScrollbar = function useScrollbar(props) {
|
|
|
134
135
|
* @ui
|
|
135
136
|
* @private
|
|
136
137
|
*/
|
|
137
|
-
var Scrollbar = exports.ScrollbarBase = exports.Scrollbar = /*#__PURE__*/(0, _react.memo)(function (
|
|
138
|
+
var Scrollbar = exports.ScrollbarBase = exports.Scrollbar = /*#__PURE__*/(0, _react.memo)(function (_ref) {
|
|
139
|
+
var _ref$corner = _ref.corner,
|
|
140
|
+
corner = _ref$corner === void 0 ? false : _ref$corner,
|
|
141
|
+
_ref$css = _ref.css,
|
|
142
|
+
css = _ref$css === void 0 ? _ScrollbarModule["default"] : _ref$css,
|
|
143
|
+
_ref$minThumbSize = _ref.minThumbSize,
|
|
144
|
+
minThumbSize = _ref$minThumbSize === void 0 ? 18 : _ref$minThumbSize,
|
|
145
|
+
_ref$vertical = _ref.vertical,
|
|
146
|
+
vertical = _ref$vertical === void 0 ? true : _ref$vertical,
|
|
147
|
+
rest = _objectWithoutProperties(_ref, _excluded2);
|
|
148
|
+
var props = _objectSpread({
|
|
149
|
+
corner: corner,
|
|
150
|
+
css: css,
|
|
151
|
+
minThumbSize: minThumbSize,
|
|
152
|
+
vertical: vertical
|
|
153
|
+
}, rest);
|
|
138
154
|
var _useScrollbar = useScrollbar(props),
|
|
139
155
|
restProps = _useScrollbar.restProps,
|
|
140
156
|
scrollbarProps = _useScrollbar.scrollbarProps,
|
|
@@ -195,10 +211,4 @@ Scrollbar.propTypes = /** @lends ui/useScroll.Scrollbar.prototype */{
|
|
|
195
211
|
*/
|
|
196
212
|
vertical: _propTypes["default"].bool
|
|
197
213
|
};
|
|
198
|
-
Scrollbar.defaultProps = {
|
|
199
|
-
corner: false,
|
|
200
|
-
css: _ScrollbarModule["default"],
|
|
201
|
-
minThumbSize: 18,
|
|
202
|
-
vertical: true
|
|
203
|
-
};
|
|
204
214
|
var _default = exports["default"] = Scrollbar;
|
|
@@ -27,7 +27,8 @@ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e =
|
|
|
27
27
|
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
28
28
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
29
29
|
var ScrollbarTrack = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
30
|
-
var vertical = props.vertical,
|
|
30
|
+
var _props$vertical = props.vertical,
|
|
31
|
+
vertical = _props$vertical === void 0 ? true : _props$vertical,
|
|
31
32
|
rest = _objectWithoutProperties(props, _excluded),
|
|
32
33
|
className = (0, _classnames["default"])(_ScrollbarTrackModule["default"].scrollbarTrack, vertical ? _ScrollbarTrackModule["default"].vertical : null);
|
|
33
34
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", _objectSpread(_objectSpread({}, rest), {}, {
|
|
@@ -45,9 +46,6 @@ ScrollbarTrack.propTypes = /** @lends ui/useScroll.ScrollbarTrack.prototype */{
|
|
|
45
46
|
*/
|
|
46
47
|
vertical: _propTypes["default"].bool
|
|
47
48
|
};
|
|
48
|
-
ScrollbarTrack.defaultProps = {
|
|
49
|
-
vertical: true
|
|
50
|
-
};
|
|
51
49
|
var MemoizedScrollbarTrack = exports.ScrollbarTrackBase = exports.MemoizedScrollbarTrack = /*#__PURE__*/(0, _react.memo)(ScrollbarTrack);
|
|
52
50
|
MemoizedScrollbarTrack.displayName = 'ui:ScrollbarTrack';
|
|
53
51
|
var _default = exports["default"] = MemoizedScrollbarTrack;
|