laymur 0.3.28 → 0.3.29
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/dist/index.d.ts +6 -1
- package/dist/index.js +226 -170
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +1 -1
- package/dist/layers/UIFullscreenLayer.d.ts +1 -1
- package/dist/miscellaneous/UIResizePolicy.d.ts +21 -0
- package/dist/miscellaneous/UIResizePolicyCross.d.ts +14 -0
- package/dist/miscellaneous/UIResizePolicyCrossInverted.d.ts +14 -0
- package/dist/miscellaneous/UIResizePolicyFixedHeight.d.ts +24 -0
- package/dist/miscellaneous/UIResizePolicyFixedWidth.d.ts +27 -0
- package/dist/miscellaneous/UIResizePolicyNone.d.ts +7 -0
- package/package.json +1 -1
- package/dist/miscellaneous/resizePolicies.d.ts +0 -99
package/dist/index.d.ts
CHANGED
|
@@ -23,7 +23,6 @@ export * from "./elements/UIScene";
|
|
|
23
23
|
export * from "./elements/UIText";
|
|
24
24
|
export * from "./layers/UIFullscreenLayer";
|
|
25
25
|
export * from "./layers/UILayer";
|
|
26
|
-
export * from "./miscellaneous/resizePolicies";
|
|
27
26
|
export * from "./miscellaneous/UIColor";
|
|
28
27
|
export * from "./miscellaneous/UIExpression";
|
|
29
28
|
export * from "./miscellaneous/UIGenericInstancedPlane";
|
|
@@ -34,6 +33,12 @@ export * from "./miscellaneous/UIMode";
|
|
|
34
33
|
export * from "./miscellaneous/UIOrientation";
|
|
35
34
|
export * from "./miscellaneous/UIPriority";
|
|
36
35
|
export * from "./miscellaneous/UIRelation";
|
|
36
|
+
export * from "./miscellaneous/UIResizePolicy";
|
|
37
|
+
export * from "./miscellaneous/UIResizePolicyCross";
|
|
38
|
+
export * from "./miscellaneous/UIResizePolicyCrossInverted";
|
|
39
|
+
export * from "./miscellaneous/UIResizePolicyFixedHeight";
|
|
40
|
+
export * from "./miscellaneous/UIResizePolicyFixedWidth";
|
|
41
|
+
export * from "./miscellaneous/UIResizePolicyNone";
|
|
37
42
|
export * from "./miscellaneous/UISceneWrapperClientAPI";
|
|
38
43
|
export * from "./miscellaneous/UITextPadding";
|
|
39
44
|
export * from "./miscellaneous/UITextSpan";
|
package/dist/index.js
CHANGED
|
@@ -6704,6 +6704,7 @@ var UIResizePolicyEvent;
|
|
|
6704
6704
|
*/
|
|
6705
6705
|
class UIResizePolicy extends i {
|
|
6706
6706
|
}
|
|
6707
|
+
|
|
6707
6708
|
/**
|
|
6708
6709
|
* No scaling applied, always returns 1:1 scale.
|
|
6709
6710
|
*/
|
|
@@ -6712,174 +6713,6 @@ class UIResizePolicyNone extends UIResizePolicy {
|
|
|
6712
6713
|
return 1;
|
|
6713
6714
|
}
|
|
6714
6715
|
}
|
|
6715
|
-
/**
|
|
6716
|
-
* Maintains fixed width, scales based on window width.
|
|
6717
|
-
*
|
|
6718
|
-
* Uses different widths for landscape vs portrait orientation.
|
|
6719
|
-
*/
|
|
6720
|
-
class UIResizePolicyFixedWidth extends UIResizePolicy {
|
|
6721
|
-
/**
|
|
6722
|
-
* @param fixedWidthLandscape - Target width for landscape (width > height)
|
|
6723
|
-
* @param fixedWidthPortrait - Target width for portrait (width <= height)
|
|
6724
|
-
*/
|
|
6725
|
-
constructor(fixedWidthLandscape, fixedWidthPortrait) {
|
|
6726
|
-
super();
|
|
6727
|
-
assertValidPositiveNumber(fixedWidthLandscape, "UIResizePolicyFixedWidth.fixedWidthLandscape");
|
|
6728
|
-
assertValidPositiveNumber(fixedWidthPortrait, "UIResizePolicyFixedWidth.fixedWidthPortrait");
|
|
6729
|
-
this._private_fixedWidthLandscapeInternal = fixedWidthLandscape;
|
|
6730
|
-
this._private_fixedWidthPortraitInternal = fixedWidthPortrait;
|
|
6731
|
-
}
|
|
6732
|
-
get fixedWidthLandscape() {
|
|
6733
|
-
return this._private_fixedWidthLandscapeInternal;
|
|
6734
|
-
}
|
|
6735
|
-
get fixedWidthPortrait() {
|
|
6736
|
-
return this._private_fixedWidthPortraitInternal;
|
|
6737
|
-
}
|
|
6738
|
-
set fixedWidthLandscape(value) {
|
|
6739
|
-
assertValidPositiveNumber(value, "UIResizePolicyFixedWidth.fixedWidthLandscape");
|
|
6740
|
-
if (value !== this._private_fixedWidthLandscapeInternal) {
|
|
6741
|
-
this._private_fixedWidthLandscapeInternal = value;
|
|
6742
|
-
this.emit(UIResizePolicyEvent.CHANGE);
|
|
6743
|
-
}
|
|
6744
|
-
}
|
|
6745
|
-
set fixedWidthPortrait(value) {
|
|
6746
|
-
assertValidPositiveNumber(value, "UIResizePolicyFixedWidth.fixedWidthPortrait");
|
|
6747
|
-
if (value !== this._private_fixedWidthPortraitInternal) {
|
|
6748
|
-
this._private_fixedWidthPortraitInternal = value;
|
|
6749
|
-
this.emit(UIResizePolicyEvent.CHANGE);
|
|
6750
|
-
}
|
|
6751
|
-
}
|
|
6752
|
-
calculateScaleInternal(width, height) {
|
|
6753
|
-
return width > height
|
|
6754
|
-
? this._private_fixedWidthLandscapeInternal / width
|
|
6755
|
-
: this._private_fixedWidthPortraitInternal / width;
|
|
6756
|
-
}
|
|
6757
|
-
}
|
|
6758
|
-
/**
|
|
6759
|
-
* Maintains fixed height, scales based on window height.
|
|
6760
|
-
*
|
|
6761
|
-
* Uses different heights for landscape vs portrait orientation.
|
|
6762
|
-
*/
|
|
6763
|
-
class UIResizePolicyFixedHeight extends UIResizePolicy {
|
|
6764
|
-
/**
|
|
6765
|
-
* @param fixedHeightLandscape - Target height for landscape (width > height)
|
|
6766
|
-
* @param fixedHeightPortrait - Target height for portrait (width <= height)
|
|
6767
|
-
*/
|
|
6768
|
-
constructor(fixedHeightLandscape, fixedHeightPortrait) {
|
|
6769
|
-
super();
|
|
6770
|
-
assertValidPositiveNumber(fixedHeightLandscape, "UIResizePolicyFixedHeight.fixedHeightLandscape");
|
|
6771
|
-
assertValidPositiveNumber(fixedHeightPortrait, "UIResizePolicyFixedHeight.fixedHeightPortrait");
|
|
6772
|
-
this._private_fixedHeightLandscapeInternal = fixedHeightLandscape;
|
|
6773
|
-
this._private_fixedHeightPortraitInternal = fixedHeightPortrait;
|
|
6774
|
-
}
|
|
6775
|
-
get fixedHeightLandscape() {
|
|
6776
|
-
return this._private_fixedHeightLandscapeInternal;
|
|
6777
|
-
}
|
|
6778
|
-
get fixedHeightPortrait() {
|
|
6779
|
-
return this._private_fixedHeightPortraitInternal;
|
|
6780
|
-
}
|
|
6781
|
-
set fixedHeightLandscape(value) {
|
|
6782
|
-
assertValidPositiveNumber(value, "UIResizePolicyFixedHeight.fixedHeightLandscape");
|
|
6783
|
-
if (value !== this._private_fixedHeightLandscapeInternal) {
|
|
6784
|
-
this._private_fixedHeightLandscapeInternal = value;
|
|
6785
|
-
this.emit(UIResizePolicyEvent.CHANGE);
|
|
6786
|
-
}
|
|
6787
|
-
}
|
|
6788
|
-
set fixedHeightPortrait(value) {
|
|
6789
|
-
assertValidPositiveNumber(value, "UIResizePolicyFixedHeight.fixedHeightPortrait");
|
|
6790
|
-
if (value !== this._private_fixedHeightPortraitInternal) {
|
|
6791
|
-
this._private_fixedHeightPortraitInternal = value;
|
|
6792
|
-
this.emit(UIResizePolicyEvent.CHANGE);
|
|
6793
|
-
}
|
|
6794
|
-
}
|
|
6795
|
-
calculateScaleInternal(width, height) {
|
|
6796
|
-
return width > height
|
|
6797
|
-
? this._private_fixedHeightLandscapeInternal / height
|
|
6798
|
-
: this._private_fixedHeightPortraitInternal / height;
|
|
6799
|
-
}
|
|
6800
|
-
}
|
|
6801
|
-
/**
|
|
6802
|
-
* Scales by width in landscape, by height in portrait.
|
|
6803
|
-
*/
|
|
6804
|
-
class UIResizePolicyCross extends UIResizePolicy {
|
|
6805
|
-
/**
|
|
6806
|
-
* @param fixedWidthLandscape - Target width for landscape
|
|
6807
|
-
* @param fixedHeightPortrait - Target height for portrait
|
|
6808
|
-
*/
|
|
6809
|
-
constructor(fixedWidthLandscape, fixedHeightPortrait) {
|
|
6810
|
-
super();
|
|
6811
|
-
assertValidPositiveNumber(fixedWidthLandscape, "UIResizePolicyCross.fixedWidthLandscape");
|
|
6812
|
-
assertValidPositiveNumber(fixedHeightPortrait, "UIResizePolicyCross.fixedHeightPortrait");
|
|
6813
|
-
this._private_fixedWidthLandscapeInternal = fixedWidthLandscape;
|
|
6814
|
-
this._private_fixedHeightPortraitInternal = fixedHeightPortrait;
|
|
6815
|
-
}
|
|
6816
|
-
get fixedWidthLandscape() {
|
|
6817
|
-
return this._private_fixedWidthLandscapeInternal;
|
|
6818
|
-
}
|
|
6819
|
-
get fixedHeightPortrait() {
|
|
6820
|
-
return this._private_fixedHeightPortraitInternal;
|
|
6821
|
-
}
|
|
6822
|
-
set fixedWidthLandscape(value) {
|
|
6823
|
-
assertValidPositiveNumber(value, "UIResizePolicyCross.fixedWidthLandscape");
|
|
6824
|
-
if (value !== this._private_fixedWidthLandscapeInternal) {
|
|
6825
|
-
this._private_fixedWidthLandscapeInternal = value;
|
|
6826
|
-
this.emit(UIResizePolicyEvent.CHANGE);
|
|
6827
|
-
}
|
|
6828
|
-
}
|
|
6829
|
-
set fixedHeightPortrait(value) {
|
|
6830
|
-
assertValidPositiveNumber(value, "UIResizePolicyCross.fixedHeightPortrait");
|
|
6831
|
-
if (value !== this._private_fixedHeightPortraitInternal) {
|
|
6832
|
-
this._private_fixedHeightPortraitInternal = value;
|
|
6833
|
-
this.emit(UIResizePolicyEvent.CHANGE);
|
|
6834
|
-
}
|
|
6835
|
-
}
|
|
6836
|
-
calculateScaleInternal(width, height) {
|
|
6837
|
-
return width > height
|
|
6838
|
-
? this._private_fixedWidthLandscapeInternal / width
|
|
6839
|
-
: this._private_fixedHeightPortraitInternal / height;
|
|
6840
|
-
}
|
|
6841
|
-
}
|
|
6842
|
-
/**
|
|
6843
|
-
* Scales by height in landscape, by width in portrait.
|
|
6844
|
-
*/
|
|
6845
|
-
class UIResizePolicyCrossInverted extends UIResizePolicy {
|
|
6846
|
-
/**
|
|
6847
|
-
* @param fixedHeightLandscape - Target height for landscape
|
|
6848
|
-
* @param fixedWidthPortrait - Target width for portrait
|
|
6849
|
-
*/
|
|
6850
|
-
constructor(fixedHeightLandscape, fixedWidthPortrait) {
|
|
6851
|
-
super();
|
|
6852
|
-
assertValidPositiveNumber(fixedHeightLandscape, "UIResizePolicyCrossInverted.fixedHeightLandscape");
|
|
6853
|
-
assertValidPositiveNumber(fixedWidthPortrait, "UIResizePolicyCrossInverted.fixedWidthPortrait");
|
|
6854
|
-
this._private_fixedHeightLandscapeInternal = fixedHeightLandscape;
|
|
6855
|
-
this._private_fixedWidthPortraitInternal = fixedWidthPortrait;
|
|
6856
|
-
}
|
|
6857
|
-
get fixedHeightLandscape() {
|
|
6858
|
-
return this._private_fixedHeightLandscapeInternal;
|
|
6859
|
-
}
|
|
6860
|
-
get fixedWidthPortrait() {
|
|
6861
|
-
return this._private_fixedWidthPortraitInternal;
|
|
6862
|
-
}
|
|
6863
|
-
set fixedHeightLandscape(value) {
|
|
6864
|
-
assertValidPositiveNumber(value, "UIResizePolicyCrossInverted.fixedHeightLandscape");
|
|
6865
|
-
if (value !== this._private_fixedHeightLandscapeInternal) {
|
|
6866
|
-
this._private_fixedHeightLandscapeInternal = value;
|
|
6867
|
-
this.emit(UIResizePolicyEvent.CHANGE);
|
|
6868
|
-
}
|
|
6869
|
-
}
|
|
6870
|
-
set fixedWidthPortrait(value) {
|
|
6871
|
-
assertValidPositiveNumber(value, "UIResizePolicyCrossInverted.fixedWidthPortrait");
|
|
6872
|
-
if (value !== this._private_fixedWidthPortraitInternal) {
|
|
6873
|
-
this._private_fixedWidthPortraitInternal = value;
|
|
6874
|
-
this.emit(UIResizePolicyEvent.CHANGE);
|
|
6875
|
-
}
|
|
6876
|
-
}
|
|
6877
|
-
calculateScaleInternal(width, height) {
|
|
6878
|
-
return width > height
|
|
6879
|
-
? this._private_fixedHeightLandscapeInternal / height
|
|
6880
|
-
: this._private_fixedWidthPortraitInternal / width;
|
|
6881
|
-
}
|
|
6882
|
-
}
|
|
6883
6716
|
|
|
6884
6717
|
/**
|
|
6885
6718
|
* UI layer that covers the full browser window.
|
|
@@ -6900,7 +6733,7 @@ class UIFullscreenLayer extends UILayer {
|
|
|
6900
6733
|
* Handles window resize. Updates layer dimensions according to resize policy.
|
|
6901
6734
|
*/
|
|
6902
6735
|
this._private_onResize = () => {
|
|
6903
|
-
const scale = this._private_resizePolicyInternal
|
|
6736
|
+
const scale = this._private_resizePolicyInternal["calculateScaleInternal"](window.innerWidth, window.innerHeight);
|
|
6904
6737
|
this.resizeInternal(window.innerWidth * scale, window.innerHeight * scale);
|
|
6905
6738
|
};
|
|
6906
6739
|
/**
|
|
@@ -6917,7 +6750,7 @@ class UIFullscreenLayer extends UILayer {
|
|
|
6917
6750
|
const y = rect
|
|
6918
6751
|
? rect.bottom - event.clientY
|
|
6919
6752
|
: window.innerHeight - event.clientY;
|
|
6920
|
-
const scale = this._private_resizePolicyInternal
|
|
6753
|
+
const scale = this._private_resizePolicyInternal["calculateScaleInternal"](window.innerWidth, window.innerHeight);
|
|
6921
6754
|
this.pointerClickInternal(x * scale, y * scale);
|
|
6922
6755
|
};
|
|
6923
6756
|
window.addEventListener("resize", this._private_onResize);
|
|
@@ -7371,6 +7204,229 @@ class UIGenericInstancedPlane extends Mesh {
|
|
|
7371
7204
|
}
|
|
7372
7205
|
}
|
|
7373
7206
|
|
|
7207
|
+
/**
|
|
7208
|
+
* Scales by width in landscape, by height in portrait.
|
|
7209
|
+
*/
|
|
7210
|
+
class UIResizePolicyCross extends UIResizePolicy {
|
|
7211
|
+
constructor(fixedWidthLandscape, fixedHeightPortrait) {
|
|
7212
|
+
super();
|
|
7213
|
+
assertValidPositiveNumber(fixedWidthLandscape, "UIResizePolicyCross.fixedWidthLandscape");
|
|
7214
|
+
assertValidPositiveNumber(fixedHeightPortrait, "UIResizePolicyCross.fixedHeightPortrait");
|
|
7215
|
+
this._private_fixedWidthLandscapeInternal = fixedWidthLandscape;
|
|
7216
|
+
this._private_fixedHeightPortraitInternal = fixedHeightPortrait;
|
|
7217
|
+
}
|
|
7218
|
+
get fixedWidthLandscape() {
|
|
7219
|
+
return this._private_fixedWidthLandscapeInternal;
|
|
7220
|
+
}
|
|
7221
|
+
get fixedHeightPortrait() {
|
|
7222
|
+
return this._private_fixedHeightPortraitInternal;
|
|
7223
|
+
}
|
|
7224
|
+
set fixedWidthLandscape(value) {
|
|
7225
|
+
assertValidPositiveNumber(value, "UIResizePolicyCross.fixedWidthLandscape");
|
|
7226
|
+
if (value !== this._private_fixedWidthLandscapeInternal) {
|
|
7227
|
+
this._private_fixedWidthLandscapeInternal = value;
|
|
7228
|
+
this.emit(UIResizePolicyEvent.CHANGE);
|
|
7229
|
+
}
|
|
7230
|
+
}
|
|
7231
|
+
set fixedHeightPortrait(value) {
|
|
7232
|
+
assertValidPositiveNumber(value, "UIResizePolicyCross.fixedHeightPortrait");
|
|
7233
|
+
if (value !== this._private_fixedHeightPortraitInternal) {
|
|
7234
|
+
this._private_fixedHeightPortraitInternal = value;
|
|
7235
|
+
this.emit(UIResizePolicyEvent.CHANGE);
|
|
7236
|
+
}
|
|
7237
|
+
}
|
|
7238
|
+
calculateScaleInternal(width, height) {
|
|
7239
|
+
return width > height
|
|
7240
|
+
? this._private_fixedWidthLandscapeInternal / width
|
|
7241
|
+
: this._private_fixedHeightPortraitInternal / height;
|
|
7242
|
+
}
|
|
7243
|
+
}
|
|
7244
|
+
|
|
7245
|
+
/**
|
|
7246
|
+
* Scales by height in landscape, by width in portrait.
|
|
7247
|
+
*/
|
|
7248
|
+
class UIResizePolicyCrossInverted extends UIResizePolicy {
|
|
7249
|
+
constructor(fixedHeightLandscape, fixedWidthPortrait) {
|
|
7250
|
+
super();
|
|
7251
|
+
assertValidPositiveNumber(fixedHeightLandscape, "UIResizePolicyCrossInverted.fixedHeightLandscape");
|
|
7252
|
+
assertValidPositiveNumber(fixedWidthPortrait, "UIResizePolicyCrossInverted.fixedWidthPortrait");
|
|
7253
|
+
this._private_fixedHeightLandscapeInternal = fixedHeightLandscape;
|
|
7254
|
+
this._private_fixedWidthPortraitInternal = fixedWidthPortrait;
|
|
7255
|
+
}
|
|
7256
|
+
get fixedHeightLandscape() {
|
|
7257
|
+
return this._private_fixedHeightLandscapeInternal;
|
|
7258
|
+
}
|
|
7259
|
+
get fixedWidthPortrait() {
|
|
7260
|
+
return this._private_fixedWidthPortraitInternal;
|
|
7261
|
+
}
|
|
7262
|
+
set fixedHeightLandscape(value) {
|
|
7263
|
+
assertValidPositiveNumber(value, "UIResizePolicyCrossInverted.fixedHeightLandscape");
|
|
7264
|
+
if (value !== this._private_fixedHeightLandscapeInternal) {
|
|
7265
|
+
this._private_fixedHeightLandscapeInternal = value;
|
|
7266
|
+
this.emit(UIResizePolicyEvent.CHANGE);
|
|
7267
|
+
}
|
|
7268
|
+
}
|
|
7269
|
+
set fixedWidthPortrait(value) {
|
|
7270
|
+
assertValidPositiveNumber(value, "UIResizePolicyCrossInverted.fixedWidthPortrait");
|
|
7271
|
+
if (value !== this._private_fixedWidthPortraitInternal) {
|
|
7272
|
+
this._private_fixedWidthPortraitInternal = value;
|
|
7273
|
+
this.emit(UIResizePolicyEvent.CHANGE);
|
|
7274
|
+
}
|
|
7275
|
+
}
|
|
7276
|
+
calculateScaleInternal(width, height) {
|
|
7277
|
+
return width > height
|
|
7278
|
+
? this._private_fixedHeightLandscapeInternal / height
|
|
7279
|
+
: this._private_fixedWidthPortraitInternal / width;
|
|
7280
|
+
}
|
|
7281
|
+
}
|
|
7282
|
+
|
|
7283
|
+
/**
|
|
7284
|
+
* Maintains fixed height, scales based on window height.
|
|
7285
|
+
*
|
|
7286
|
+
* Uses different heights for landscape vs portrait orientation,
|
|
7287
|
+
* and optionally for near-square aspect ratios.
|
|
7288
|
+
*/
|
|
7289
|
+
class UIResizePolicyFixedHeight extends UIResizePolicy {
|
|
7290
|
+
constructor(fixedHeightLandscape, fixedHeightPortrait, fixedHeightSquare = fixedHeightPortrait, squareEpsilon = 0.1) {
|
|
7291
|
+
super();
|
|
7292
|
+
assertValidPositiveNumber(fixedHeightLandscape, "UIResizePolicyFixedHeight.fixedHeightLandscape");
|
|
7293
|
+
assertValidPositiveNumber(fixedHeightPortrait, "UIResizePolicyFixedHeight.fixedHeightPortrait");
|
|
7294
|
+
assertValidPositiveNumber(fixedHeightSquare, "UIResizePolicyFixedHeight.fixedHeightSquare");
|
|
7295
|
+
assertValidPositiveNumber(squareEpsilon, "UIResizePolicy.squareEpsilon");
|
|
7296
|
+
this._private_fixedHeightLandscapeInternal = fixedHeightLandscape;
|
|
7297
|
+
this._private_fixedHeightPortraitInternal = fixedHeightPortrait;
|
|
7298
|
+
this._private_fixedHeightSquareInternal = fixedHeightSquare;
|
|
7299
|
+
this._private_squareEpsilonInternal = squareEpsilon;
|
|
7300
|
+
}
|
|
7301
|
+
get fixedHeightLandscape() {
|
|
7302
|
+
return this._private_fixedHeightLandscapeInternal;
|
|
7303
|
+
}
|
|
7304
|
+
get fixedHeightPortrait() {
|
|
7305
|
+
return this._private_fixedHeightPortraitInternal;
|
|
7306
|
+
}
|
|
7307
|
+
get fixedHeightSquare() {
|
|
7308
|
+
return this._private_fixedHeightSquareInternal;
|
|
7309
|
+
}
|
|
7310
|
+
get squareEpsilon() {
|
|
7311
|
+
return this._private_squareEpsilonInternal;
|
|
7312
|
+
}
|
|
7313
|
+
set fixedHeightLandscape(value) {
|
|
7314
|
+
assertValidPositiveNumber(value, "UIResizePolicyFixedHeight.fixedHeightLandscape");
|
|
7315
|
+
if (value !== this._private_fixedHeightLandscapeInternal) {
|
|
7316
|
+
this._private_fixedHeightLandscapeInternal = value;
|
|
7317
|
+
this.emit(UIResizePolicyEvent.CHANGE);
|
|
7318
|
+
}
|
|
7319
|
+
}
|
|
7320
|
+
set fixedHeightPortrait(value) {
|
|
7321
|
+
assertValidPositiveNumber(value, "UIResizePolicyFixedHeight.fixedHeightPortrait");
|
|
7322
|
+
if (value !== this._private_fixedHeightPortraitInternal) {
|
|
7323
|
+
this._private_fixedHeightPortraitInternal = value;
|
|
7324
|
+
this.emit(UIResizePolicyEvent.CHANGE);
|
|
7325
|
+
}
|
|
7326
|
+
}
|
|
7327
|
+
set fixedHeightSquare(value) {
|
|
7328
|
+
assertValidPositiveNumber(value, "UIResizePolicyFixedHeight.fixedHeightSquare");
|
|
7329
|
+
if (value !== this._private_fixedHeightSquareInternal) {
|
|
7330
|
+
this._private_fixedHeightSquareInternal = value;
|
|
7331
|
+
this.emit(UIResizePolicyEvent.CHANGE);
|
|
7332
|
+
}
|
|
7333
|
+
}
|
|
7334
|
+
set squareEpsilon(value) {
|
|
7335
|
+
assertValidPositiveNumber(value, "UIResizePolicy.squareEpsilon");
|
|
7336
|
+
if (value !== this._private_squareEpsilonInternal) {
|
|
7337
|
+
this._private_squareEpsilonInternal = value;
|
|
7338
|
+
this.emit(UIResizePolicyEvent.CHANGE);
|
|
7339
|
+
}
|
|
7340
|
+
}
|
|
7341
|
+
calculateScaleInternal(width, height) {
|
|
7342
|
+
if (this._private_isSquare(width, height)) {
|
|
7343
|
+
return this._private_fixedHeightSquareInternal / height;
|
|
7344
|
+
}
|
|
7345
|
+
return width > height
|
|
7346
|
+
? this._private_fixedHeightLandscapeInternal / height
|
|
7347
|
+
: this._private_fixedHeightPortraitInternal / height;
|
|
7348
|
+
}
|
|
7349
|
+
_private_isSquare(width, height) {
|
|
7350
|
+
const ratio = width / height;
|
|
7351
|
+
return Math.abs(ratio - 1) <= this._private_squareEpsilonInternal;
|
|
7352
|
+
}
|
|
7353
|
+
}
|
|
7354
|
+
|
|
7355
|
+
/**
|
|
7356
|
+
* Maintains fixed width, scales based on window width.
|
|
7357
|
+
*
|
|
7358
|
+
* Uses different widths for landscape vs portrait orientation, and optionally
|
|
7359
|
+
* a third width for near-square aspect ratios.
|
|
7360
|
+
*/
|
|
7361
|
+
class UIResizePolicyFixedWidth extends UIResizePolicy {
|
|
7362
|
+
constructor(fixedWidthLandscape, fixedWidthPortrait, fixedWidthSquare = fixedWidthPortrait, squareEpsilon = 0.1) {
|
|
7363
|
+
super();
|
|
7364
|
+
assertValidPositiveNumber(fixedWidthLandscape, "UIResizePolicyFixedWidth.fixedWidthLandscape");
|
|
7365
|
+
assertValidPositiveNumber(fixedWidthPortrait, "UIResizePolicyFixedWidth.fixedWidthPortrait");
|
|
7366
|
+
assertValidPositiveNumber(fixedWidthSquare, "UIResizePolicyFixedWidth.fixedWidthSquare");
|
|
7367
|
+
assertValidPositiveNumber(squareEpsilon, "UIResizePolicy.squareEpsilon");
|
|
7368
|
+
this._private_fixedWidthLandscapeInternal = fixedWidthLandscape;
|
|
7369
|
+
this._private_fixedWidthPortraitInternal = fixedWidthPortrait;
|
|
7370
|
+
this._private_fixedWidthSquareInternal = fixedWidthSquare;
|
|
7371
|
+
this._private_squareEpsilonInternal = squareEpsilon;
|
|
7372
|
+
}
|
|
7373
|
+
get fixedWidthLandscape() {
|
|
7374
|
+
return this._private_fixedWidthLandscapeInternal;
|
|
7375
|
+
}
|
|
7376
|
+
get fixedWidthPortrait() {
|
|
7377
|
+
return this._private_fixedWidthPortraitInternal;
|
|
7378
|
+
}
|
|
7379
|
+
get fixedWidthSquare() {
|
|
7380
|
+
return this._private_fixedWidthSquareInternal;
|
|
7381
|
+
}
|
|
7382
|
+
get squareEpsilon() {
|
|
7383
|
+
return this._private_squareEpsilonInternal;
|
|
7384
|
+
}
|
|
7385
|
+
set fixedWidthLandscape(value) {
|
|
7386
|
+
assertValidPositiveNumber(value, "UIResizePolicyFixedWidth.fixedWidthLandscape");
|
|
7387
|
+
if (value !== this._private_fixedWidthLandscapeInternal) {
|
|
7388
|
+
this._private_fixedWidthLandscapeInternal = value;
|
|
7389
|
+
this.emit(UIResizePolicyEvent.CHANGE);
|
|
7390
|
+
}
|
|
7391
|
+
}
|
|
7392
|
+
set fixedWidthPortrait(value) {
|
|
7393
|
+
assertValidPositiveNumber(value, "UIResizePolicyFixedWidth.fixedWidthPortrait");
|
|
7394
|
+
if (value !== this._private_fixedWidthPortraitInternal) {
|
|
7395
|
+
this._private_fixedWidthPortraitInternal = value;
|
|
7396
|
+
this.emit(UIResizePolicyEvent.CHANGE);
|
|
7397
|
+
}
|
|
7398
|
+
}
|
|
7399
|
+
set fixedWidthSquare(value) {
|
|
7400
|
+
assertValidPositiveNumber(value, "UIResizePolicyFixedWidth.fixedWidthSquare");
|
|
7401
|
+
if (value !== this._private_fixedWidthSquareInternal) {
|
|
7402
|
+
this._private_fixedWidthSquareInternal = value;
|
|
7403
|
+
this.emit(UIResizePolicyEvent.CHANGE);
|
|
7404
|
+
}
|
|
7405
|
+
}
|
|
7406
|
+
set squareEpsilon(value) {
|
|
7407
|
+
assertValidPositiveNumber(value, "UIResizePolicy.squareEpsilon");
|
|
7408
|
+
if (value !== this._private_squareEpsilonInternal) {
|
|
7409
|
+
this._private_squareEpsilonInternal = value;
|
|
7410
|
+
this.emit(UIResizePolicyEvent.CHANGE);
|
|
7411
|
+
}
|
|
7412
|
+
}
|
|
7413
|
+
calculateScaleInternal(width, height) {
|
|
7414
|
+
if (this._private_isSquare(width, height)) {
|
|
7415
|
+
return this._private_fixedWidthSquareInternal / width;
|
|
7416
|
+
}
|
|
7417
|
+
return width > height
|
|
7418
|
+
? this._private_fixedWidthLandscapeInternal / width
|
|
7419
|
+
: this._private_fixedWidthPortraitInternal / width;
|
|
7420
|
+
}
|
|
7421
|
+
/**
|
|
7422
|
+
* Determines if viewport aspect ratio is close to 1:1.
|
|
7423
|
+
*/
|
|
7424
|
+
_private_isSquare(width, height) {
|
|
7425
|
+
const ratio = width / height;
|
|
7426
|
+
return Math.abs(ratio - 1) <= this._private_squareEpsilonInternal;
|
|
7427
|
+
}
|
|
7428
|
+
}
|
|
7429
|
+
|
|
7374
7430
|
function isUITextSpan(obj) {
|
|
7375
7431
|
return (obj !== null &&
|
|
7376
7432
|
typeof obj === "object" &&
|