@hkdigital/lib-core 0.4.99 → 0.5.1
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.
|
@@ -79,16 +79,38 @@
|
|
|
79
79
|
|
|
80
80
|
let debouncedWindowWidth = $state();
|
|
81
81
|
let debouncedWindowHeight = $state();
|
|
82
|
+
|
|
82
83
|
let debounceTimer;
|
|
83
84
|
|
|
84
|
-
let
|
|
85
|
-
let
|
|
85
|
+
let gameWidthOnPortrait = $state();
|
|
86
|
+
let gameHeightOnPortrait = $state();
|
|
87
|
+
|
|
88
|
+
let gameWidthOnLandscape = $state();
|
|
89
|
+
let gameHeightOnLandscape = $state();
|
|
86
90
|
|
|
87
91
|
let iosWindowWidth = $state();
|
|
88
92
|
let iosWindowHeight = $state();
|
|
89
93
|
|
|
90
94
|
let isLandscape = $state();
|
|
91
95
|
|
|
96
|
+
let gameWidth = $derived.by( () => {
|
|
97
|
+
if( isLandscape ) {
|
|
98
|
+
return gameWidthOnLandscape;
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
return gameWidthOnPortrait;
|
|
102
|
+
}
|
|
103
|
+
} );
|
|
104
|
+
|
|
105
|
+
let gameHeight = $derived.by( () => {
|
|
106
|
+
if( isLandscape ) {
|
|
107
|
+
return gameHeightOnLandscape;
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
110
|
+
return gameHeightOnPortrait;
|
|
111
|
+
}
|
|
112
|
+
} );
|
|
113
|
+
|
|
92
114
|
const isAppleMobile = /iPhone|iPod/.test(navigator.userAgent);
|
|
93
115
|
|
|
94
116
|
// Debounce window dimensions on iOS to skip intermediate resize events
|
|
@@ -175,28 +197,38 @@
|
|
|
175
197
|
// marginBottom
|
|
176
198
|
// });
|
|
177
199
|
|
|
178
|
-
let gameAspect;
|
|
179
|
-
|
|
180
200
|
if (availWidth > availHeight) {
|
|
181
|
-
|
|
201
|
+
gameWidthOnLandscape = getGameWidthOnLandscape({
|
|
182
202
|
windowWidth: availWidth,
|
|
183
203
|
windowHeight: availHeight,
|
|
184
204
|
aspectOnLandscape
|
|
185
205
|
});
|
|
186
|
-
|
|
206
|
+
|
|
207
|
+
if( aspectOnLandscape )
|
|
208
|
+
{
|
|
209
|
+
gameHeightOnLandscape = gameWidthOnLandscape / aspectOnLandscape;
|
|
210
|
+
}
|
|
211
|
+
else {
|
|
212
|
+
gameHeightOnLandscape = availHeight;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
isLandscape = true;
|
|
187
216
|
} else {
|
|
188
|
-
|
|
217
|
+
gameWidthOnPortrait = getGameWidthOnPortrait({
|
|
189
218
|
windowWidth: availWidth,
|
|
190
219
|
windowHeight: availHeight,
|
|
191
220
|
aspectOnPortrait
|
|
192
221
|
});
|
|
193
|
-
gameAspect = aspectOnPortrait;
|
|
194
|
-
}
|
|
195
222
|
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
223
|
+
if( aspectOnPortrait )
|
|
224
|
+
{
|
|
225
|
+
gameHeightOnPortrait = gameWidthOnPortrait / aspectOnPortrait;
|
|
226
|
+
}
|
|
227
|
+
else {
|
|
228
|
+
gameHeightOnPortrait = availHeight;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
isLandscape = false;
|
|
200
232
|
}
|
|
201
233
|
});
|
|
202
234
|
|
|
@@ -403,8 +435,8 @@
|
|
|
403
435
|
<!-- Landscape content -->
|
|
404
436
|
<div
|
|
405
437
|
class:hidden={!isLandscape}
|
|
406
|
-
style:width="{
|
|
407
|
-
style:height="{
|
|
438
|
+
style:width="{gameWidthOnLandscape}px"
|
|
439
|
+
style:height="{gameHeightOnLandscape}px"
|
|
408
440
|
>
|
|
409
441
|
{@render snippetLandscape({
|
|
410
442
|
isLandscape,
|
|
@@ -424,8 +456,8 @@
|
|
|
424
456
|
<!-- Portrait content -->
|
|
425
457
|
<div
|
|
426
458
|
class:hidden={isLandscape}
|
|
427
|
-
style:width="{
|
|
428
|
-
style:height="{
|
|
459
|
+
style:width="{gameWidthOnPortrait}px"
|
|
460
|
+
style:height="{gameHeightOnPortrait}px"
|
|
429
461
|
>
|
|
430
462
|
{@render snippetPortrait({
|
|
431
463
|
isLandscape,
|
|
@@ -482,8 +514,8 @@
|
|
|
482
514
|
<!-- Landscape content -->
|
|
483
515
|
<div
|
|
484
516
|
class:hidden={!isLandscape}
|
|
485
|
-
style:width="{
|
|
486
|
-
style:height="{
|
|
517
|
+
style:width="{gameWidthOnLandscape}px"
|
|
518
|
+
style:height="{gameHeightOnLandscape}px"
|
|
487
519
|
>
|
|
488
520
|
{@render snippetLandscape({
|
|
489
521
|
isLandscape,
|
|
@@ -503,8 +535,8 @@
|
|
|
503
535
|
<!-- Portrait content -->
|
|
504
536
|
<div
|
|
505
537
|
class:hidden={isLandscape}
|
|
506
|
-
style:width="{
|
|
507
|
-
style:height="{
|
|
538
|
+
style:width="{gameWidthOnPortrait}px"
|
|
539
|
+
style:height="{gameHeightOnPortrait}px"
|
|
508
540
|
>
|
|
509
541
|
{@render snippetPortrait({
|
|
510
542
|
isLandscape,
|
|
@@ -527,8 +559,8 @@
|
|
|
527
559
|
<!-- Landscape content -->
|
|
528
560
|
<div
|
|
529
561
|
class:hidden={!isLandscape}
|
|
530
|
-
style:width="{
|
|
531
|
-
style:height="{
|
|
562
|
+
style:width="{gameWidthOnLandscape}px"
|
|
563
|
+
style:height="{gameHeightOnLandscape}px"
|
|
532
564
|
>
|
|
533
565
|
{@render snippetLandscape({
|
|
534
566
|
isLandscape,
|
|
@@ -546,8 +578,8 @@
|
|
|
546
578
|
<!-- Portrait content -->
|
|
547
579
|
<div
|
|
548
580
|
class:hidden={isLandscape}
|
|
549
|
-
style:width="{
|
|
550
|
-
style:height="{
|
|
581
|
+
style:width="{gameWidthOnPortrait}px"
|
|
582
|
+
style:height="{gameHeightOnPortrait}px"
|
|
551
583
|
>
|
|
552
584
|
{@render snippetPortrait({
|
|
553
585
|
isLandscape,
|