laymur 0.3.27 → 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 +234 -174
- 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/dist/miscellaneous/textTools.d.ts +1 -1
- 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
|
@@ -6452,8 +6452,12 @@ function renderText(x, y, text, style, context) {
|
|
|
6452
6452
|
context.fillStyle = style.color;
|
|
6453
6453
|
context.fillText(text, x, y);
|
|
6454
6454
|
}
|
|
6455
|
-
function renderTextLines(paddingTop, paddingLeft, lines, context
|
|
6455
|
+
function renderTextLines(paddingTop, paddingLeft, lines, context) {
|
|
6456
6456
|
let currentY = paddingTop;
|
|
6457
|
+
let textWidth = 0;
|
|
6458
|
+
for (const line of lines) {
|
|
6459
|
+
textWidth = Math.max(line.width, textWidth);
|
|
6460
|
+
}
|
|
6457
6461
|
for (let i = 0; i < lines.length; i++) {
|
|
6458
6462
|
const line = lines[i];
|
|
6459
6463
|
const firstAlign = line.chunks[0]?.style.align ?? DEFAULT_TEXT_STYLE.align;
|
|
@@ -6461,10 +6465,10 @@ function renderTextLines(paddingTop, paddingLeft, lines, context, maxWidth) {
|
|
|
6461
6465
|
const lineAlign = isUniformAlign ? firstAlign : DEFAULT_TEXT_STYLE.align;
|
|
6462
6466
|
let offsetX = 0;
|
|
6463
6467
|
if (lineAlign === "center") {
|
|
6464
|
-
offsetX = (
|
|
6468
|
+
offsetX = (textWidth - line.width) / 2;
|
|
6465
6469
|
}
|
|
6466
6470
|
else if (lineAlign === "right") {
|
|
6467
|
-
offsetX =
|
|
6471
|
+
offsetX = textWidth - line.width;
|
|
6468
6472
|
}
|
|
6469
6473
|
let currentX = paddingLeft + offsetX;
|
|
6470
6474
|
currentY += i === 0 ? line.height : line.lineHeight;
|
|
@@ -6680,7 +6684,7 @@ class UIText extends UIElement {
|
|
|
6680
6684
|
this.width = this._private_canvas.width;
|
|
6681
6685
|
this.height = this._private_canvas.height;
|
|
6682
6686
|
this._private_targetAspectRatio = this._private_canvas.width / this._private_canvas.height;
|
|
6683
|
-
renderTextLines(this._private_paddingInternal.top, this._private_paddingInternal.left, lines, this._private_context
|
|
6687
|
+
renderTextLines(this._private_paddingInternal.top, this._private_paddingInternal.left, lines, this._private_context);
|
|
6684
6688
|
this._private_texture.dispose();
|
|
6685
6689
|
this._private_texture = new CanvasTexture(this._private_canvas);
|
|
6686
6690
|
this._private_texture.needsUpdate = true;
|
|
@@ -6700,6 +6704,7 @@ var UIResizePolicyEvent;
|
|
|
6700
6704
|
*/
|
|
6701
6705
|
class UIResizePolicy extends i {
|
|
6702
6706
|
}
|
|
6707
|
+
|
|
6703
6708
|
/**
|
|
6704
6709
|
* No scaling applied, always returns 1:1 scale.
|
|
6705
6710
|
*/
|
|
@@ -6708,174 +6713,6 @@ class UIResizePolicyNone extends UIResizePolicy {
|
|
|
6708
6713
|
return 1;
|
|
6709
6714
|
}
|
|
6710
6715
|
}
|
|
6711
|
-
/**
|
|
6712
|
-
* Maintains fixed width, scales based on window width.
|
|
6713
|
-
*
|
|
6714
|
-
* Uses different widths for landscape vs portrait orientation.
|
|
6715
|
-
*/
|
|
6716
|
-
class UIResizePolicyFixedWidth extends UIResizePolicy {
|
|
6717
|
-
/**
|
|
6718
|
-
* @param fixedWidthLandscape - Target width for landscape (width > height)
|
|
6719
|
-
* @param fixedWidthPortrait - Target width for portrait (width <= height)
|
|
6720
|
-
*/
|
|
6721
|
-
constructor(fixedWidthLandscape, fixedWidthPortrait) {
|
|
6722
|
-
super();
|
|
6723
|
-
assertValidPositiveNumber(fixedWidthLandscape, "UIResizePolicyFixedWidth.fixedWidthLandscape");
|
|
6724
|
-
assertValidPositiveNumber(fixedWidthPortrait, "UIResizePolicyFixedWidth.fixedWidthPortrait");
|
|
6725
|
-
this._private_fixedWidthLandscapeInternal = fixedWidthLandscape;
|
|
6726
|
-
this._private_fixedWidthPortraitInternal = fixedWidthPortrait;
|
|
6727
|
-
}
|
|
6728
|
-
get fixedWidthLandscape() {
|
|
6729
|
-
return this._private_fixedWidthLandscapeInternal;
|
|
6730
|
-
}
|
|
6731
|
-
get fixedWidthPortrait() {
|
|
6732
|
-
return this._private_fixedWidthPortraitInternal;
|
|
6733
|
-
}
|
|
6734
|
-
set fixedWidthLandscape(value) {
|
|
6735
|
-
assertValidPositiveNumber(value, "UIResizePolicyFixedWidth.fixedWidthLandscape");
|
|
6736
|
-
if (value !== this._private_fixedWidthLandscapeInternal) {
|
|
6737
|
-
this._private_fixedWidthLandscapeInternal = value;
|
|
6738
|
-
this.emit(UIResizePolicyEvent.CHANGE);
|
|
6739
|
-
}
|
|
6740
|
-
}
|
|
6741
|
-
set fixedWidthPortrait(value) {
|
|
6742
|
-
assertValidPositiveNumber(value, "UIResizePolicyFixedWidth.fixedWidthPortrait");
|
|
6743
|
-
if (value !== this._private_fixedWidthPortraitInternal) {
|
|
6744
|
-
this._private_fixedWidthPortraitInternal = value;
|
|
6745
|
-
this.emit(UIResizePolicyEvent.CHANGE);
|
|
6746
|
-
}
|
|
6747
|
-
}
|
|
6748
|
-
calculateScaleInternal(width, height) {
|
|
6749
|
-
return width > height
|
|
6750
|
-
? this._private_fixedWidthLandscapeInternal / width
|
|
6751
|
-
: this._private_fixedWidthPortraitInternal / width;
|
|
6752
|
-
}
|
|
6753
|
-
}
|
|
6754
|
-
/**
|
|
6755
|
-
* Maintains fixed height, scales based on window height.
|
|
6756
|
-
*
|
|
6757
|
-
* Uses different heights for landscape vs portrait orientation.
|
|
6758
|
-
*/
|
|
6759
|
-
class UIResizePolicyFixedHeight extends UIResizePolicy {
|
|
6760
|
-
/**
|
|
6761
|
-
* @param fixedHeightLandscape - Target height for landscape (width > height)
|
|
6762
|
-
* @param fixedHeightPortrait - Target height for portrait (width <= height)
|
|
6763
|
-
*/
|
|
6764
|
-
constructor(fixedHeightLandscape, fixedHeightPortrait) {
|
|
6765
|
-
super();
|
|
6766
|
-
assertValidPositiveNumber(fixedHeightLandscape, "UIResizePolicyFixedHeight.fixedHeightLandscape");
|
|
6767
|
-
assertValidPositiveNumber(fixedHeightPortrait, "UIResizePolicyFixedHeight.fixedHeightPortrait");
|
|
6768
|
-
this._private_fixedHeightLandscapeInternal = fixedHeightLandscape;
|
|
6769
|
-
this._private_fixedHeightPortraitInternal = fixedHeightPortrait;
|
|
6770
|
-
}
|
|
6771
|
-
get fixedHeightLandscape() {
|
|
6772
|
-
return this._private_fixedHeightLandscapeInternal;
|
|
6773
|
-
}
|
|
6774
|
-
get fixedHeightPortrait() {
|
|
6775
|
-
return this._private_fixedHeightPortraitInternal;
|
|
6776
|
-
}
|
|
6777
|
-
set fixedHeightLandscape(value) {
|
|
6778
|
-
assertValidPositiveNumber(value, "UIResizePolicyFixedHeight.fixedHeightLandscape");
|
|
6779
|
-
if (value !== this._private_fixedHeightLandscapeInternal) {
|
|
6780
|
-
this._private_fixedHeightLandscapeInternal = value;
|
|
6781
|
-
this.emit(UIResizePolicyEvent.CHANGE);
|
|
6782
|
-
}
|
|
6783
|
-
}
|
|
6784
|
-
set fixedHeightPortrait(value) {
|
|
6785
|
-
assertValidPositiveNumber(value, "UIResizePolicyFixedHeight.fixedHeightPortrait");
|
|
6786
|
-
if (value !== this._private_fixedHeightPortraitInternal) {
|
|
6787
|
-
this._private_fixedHeightPortraitInternal = value;
|
|
6788
|
-
this.emit(UIResizePolicyEvent.CHANGE);
|
|
6789
|
-
}
|
|
6790
|
-
}
|
|
6791
|
-
calculateScaleInternal(width, height) {
|
|
6792
|
-
return width > height
|
|
6793
|
-
? this._private_fixedHeightLandscapeInternal / height
|
|
6794
|
-
: this._private_fixedHeightPortraitInternal / height;
|
|
6795
|
-
}
|
|
6796
|
-
}
|
|
6797
|
-
/**
|
|
6798
|
-
* Scales by width in landscape, by height in portrait.
|
|
6799
|
-
*/
|
|
6800
|
-
class UIResizePolicyCross extends UIResizePolicy {
|
|
6801
|
-
/**
|
|
6802
|
-
* @param fixedWidthLandscape - Target width for landscape
|
|
6803
|
-
* @param fixedHeightPortrait - Target height for portrait
|
|
6804
|
-
*/
|
|
6805
|
-
constructor(fixedWidthLandscape, fixedHeightPortrait) {
|
|
6806
|
-
super();
|
|
6807
|
-
assertValidPositiveNumber(fixedWidthLandscape, "UIResizePolicyCross.fixedWidthLandscape");
|
|
6808
|
-
assertValidPositiveNumber(fixedHeightPortrait, "UIResizePolicyCross.fixedHeightPortrait");
|
|
6809
|
-
this._private_fixedWidthLandscapeInternal = fixedWidthLandscape;
|
|
6810
|
-
this._private_fixedHeightPortraitInternal = fixedHeightPortrait;
|
|
6811
|
-
}
|
|
6812
|
-
get fixedWidthLandscape() {
|
|
6813
|
-
return this._private_fixedWidthLandscapeInternal;
|
|
6814
|
-
}
|
|
6815
|
-
get fixedHeightPortrait() {
|
|
6816
|
-
return this._private_fixedHeightPortraitInternal;
|
|
6817
|
-
}
|
|
6818
|
-
set fixedWidthLandscape(value) {
|
|
6819
|
-
assertValidPositiveNumber(value, "UIResizePolicyCross.fixedWidthLandscape");
|
|
6820
|
-
if (value !== this._private_fixedWidthLandscapeInternal) {
|
|
6821
|
-
this._private_fixedWidthLandscapeInternal = value;
|
|
6822
|
-
this.emit(UIResizePolicyEvent.CHANGE);
|
|
6823
|
-
}
|
|
6824
|
-
}
|
|
6825
|
-
set fixedHeightPortrait(value) {
|
|
6826
|
-
assertValidPositiveNumber(value, "UIResizePolicyCross.fixedHeightPortrait");
|
|
6827
|
-
if (value !== this._private_fixedHeightPortraitInternal) {
|
|
6828
|
-
this._private_fixedHeightPortraitInternal = value;
|
|
6829
|
-
this.emit(UIResizePolicyEvent.CHANGE);
|
|
6830
|
-
}
|
|
6831
|
-
}
|
|
6832
|
-
calculateScaleInternal(width, height) {
|
|
6833
|
-
return width > height
|
|
6834
|
-
? this._private_fixedWidthLandscapeInternal / width
|
|
6835
|
-
: this._private_fixedHeightPortraitInternal / height;
|
|
6836
|
-
}
|
|
6837
|
-
}
|
|
6838
|
-
/**
|
|
6839
|
-
* Scales by height in landscape, by width in portrait.
|
|
6840
|
-
*/
|
|
6841
|
-
class UIResizePolicyCrossInverted extends UIResizePolicy {
|
|
6842
|
-
/**
|
|
6843
|
-
* @param fixedHeightLandscape - Target height for landscape
|
|
6844
|
-
* @param fixedWidthPortrait - Target width for portrait
|
|
6845
|
-
*/
|
|
6846
|
-
constructor(fixedHeightLandscape, fixedWidthPortrait) {
|
|
6847
|
-
super();
|
|
6848
|
-
assertValidPositiveNumber(fixedHeightLandscape, "UIResizePolicyCrossInverted.fixedHeightLandscape");
|
|
6849
|
-
assertValidPositiveNumber(fixedWidthPortrait, "UIResizePolicyCrossInverted.fixedWidthPortrait");
|
|
6850
|
-
this._private_fixedHeightLandscapeInternal = fixedHeightLandscape;
|
|
6851
|
-
this._private_fixedWidthPortraitInternal = fixedWidthPortrait;
|
|
6852
|
-
}
|
|
6853
|
-
get fixedHeightLandscape() {
|
|
6854
|
-
return this._private_fixedHeightLandscapeInternal;
|
|
6855
|
-
}
|
|
6856
|
-
get fixedWidthPortrait() {
|
|
6857
|
-
return this._private_fixedWidthPortraitInternal;
|
|
6858
|
-
}
|
|
6859
|
-
set fixedHeightLandscape(value) {
|
|
6860
|
-
assertValidPositiveNumber(value, "UIResizePolicyCrossInverted.fixedHeightLandscape");
|
|
6861
|
-
if (value !== this._private_fixedHeightLandscapeInternal) {
|
|
6862
|
-
this._private_fixedHeightLandscapeInternal = value;
|
|
6863
|
-
this.emit(UIResizePolicyEvent.CHANGE);
|
|
6864
|
-
}
|
|
6865
|
-
}
|
|
6866
|
-
set fixedWidthPortrait(value) {
|
|
6867
|
-
assertValidPositiveNumber(value, "UIResizePolicyCrossInverted.fixedWidthPortrait");
|
|
6868
|
-
if (value !== this._private_fixedWidthPortraitInternal) {
|
|
6869
|
-
this._private_fixedWidthPortraitInternal = value;
|
|
6870
|
-
this.emit(UIResizePolicyEvent.CHANGE);
|
|
6871
|
-
}
|
|
6872
|
-
}
|
|
6873
|
-
calculateScaleInternal(width, height) {
|
|
6874
|
-
return width > height
|
|
6875
|
-
? this._private_fixedHeightLandscapeInternal / height
|
|
6876
|
-
: this._private_fixedWidthPortraitInternal / width;
|
|
6877
|
-
}
|
|
6878
|
-
}
|
|
6879
6716
|
|
|
6880
6717
|
/**
|
|
6881
6718
|
* UI layer that covers the full browser window.
|
|
@@ -6896,7 +6733,7 @@ class UIFullscreenLayer extends UILayer {
|
|
|
6896
6733
|
* Handles window resize. Updates layer dimensions according to resize policy.
|
|
6897
6734
|
*/
|
|
6898
6735
|
this._private_onResize = () => {
|
|
6899
|
-
const scale = this._private_resizePolicyInternal
|
|
6736
|
+
const scale = this._private_resizePolicyInternal["calculateScaleInternal"](window.innerWidth, window.innerHeight);
|
|
6900
6737
|
this.resizeInternal(window.innerWidth * scale, window.innerHeight * scale);
|
|
6901
6738
|
};
|
|
6902
6739
|
/**
|
|
@@ -6913,7 +6750,7 @@ class UIFullscreenLayer extends UILayer {
|
|
|
6913
6750
|
const y = rect
|
|
6914
6751
|
? rect.bottom - event.clientY
|
|
6915
6752
|
: window.innerHeight - event.clientY;
|
|
6916
|
-
const scale = this._private_resizePolicyInternal
|
|
6753
|
+
const scale = this._private_resizePolicyInternal["calculateScaleInternal"](window.innerWidth, window.innerHeight);
|
|
6917
6754
|
this.pointerClickInternal(x * scale, y * scale);
|
|
6918
6755
|
};
|
|
6919
6756
|
window.addEventListener("resize", this._private_onResize);
|
|
@@ -7367,6 +7204,229 @@ class UIGenericInstancedPlane extends Mesh {
|
|
|
7367
7204
|
}
|
|
7368
7205
|
}
|
|
7369
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
|
+
|
|
7370
7430
|
function isUITextSpan(obj) {
|
|
7371
7431
|
return (obj !== null &&
|
|
7372
7432
|
typeof obj === "object" &&
|