pixifact 0.1.4 → 0.2.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/dist/compiler/builtinScenes.d.ts +2 -2
- package/dist/compiler/builtinScenes.js +1 -9
- package/dist/compiler/compileScenes.js +16 -0
- package/dist/compiler/pixiNodeSchema.d.ts +17 -7
- package/dist/compiler/pixiNodeSchema.js +219 -0
- package/dist/compiler/sceneValidation.js +13 -2
- package/dist/compiler/spec.d.ts +5 -1
- package/dist/compiler/templateParser.js +18 -10
- package/dist/compiler/templateSerializer.js +1 -0
- package/dist/compiler/typescriptCompiler.js +53 -8
- package/dist/project/index.d.ts +5 -0
- package/dist/project/index.js +22 -0
- package/dist/runtime/Control.d.ts +18 -0
- package/dist/runtime/Control.js +49 -0
- package/dist/runtime/GridContainer.d.ts +25 -0
- package/dist/runtime/GridContainer.js +115 -0
- package/dist/runtime/Group.d.ts +2 -0
- package/dist/runtime/Group.js +30 -10
- package/dist/runtime/HBoxContainer.d.ts +21 -0
- package/dist/runtime/HBoxContainer.js +74 -0
- package/dist/runtime/Image.d.ts +47 -0
- package/dist/runtime/Image.js +220 -0
- package/dist/runtime/NineImage.d.ts +22 -0
- package/dist/runtime/NineImage.js +54 -0
- package/dist/runtime/Rect.d.ts +48 -0
- package/dist/runtime/Rect.js +162 -0
- package/dist/runtime/ScrollContainer.d.ts +28 -0
- package/dist/runtime/ScrollContainer.js +370 -0
- package/dist/runtime/TileImage.d.ts +27 -0
- package/dist/runtime/TileImage.js +57 -0
- package/dist/runtime/VBoxContainer.d.ts +21 -0
- package/dist/runtime/VBoxContainer.js +74 -0
- package/dist/runtime/frameLayout.d.ts +11 -0
- package/dist/runtime/frameLayout.js +116 -0
- package/dist/runtime/frameLayoutAccessors.d.ts +4 -0
- package/dist/runtime/frameLayoutAccessors.js +7 -0
- package/dist/runtime/index.d.ts +12 -0
- package/dist/runtime/index.js +12 -0
- package/dist/runtime/stackLayout.d.ts +16 -0
- package/dist/runtime/stackLayout.js +59 -0
- package/dist/viewport.d.ts +43 -0
- package/dist/viewport.js +93 -0
- package/package.json +2 -2
- package/dist/builtin-scenes/CenterContainer.d.ts +0 -13
- package/dist/builtin-scenes/CenterContainer.js +0 -71
- package/dist/builtin-scenes/CenterContainer.scene +0 -3
- package/dist/builtin-scenes/CenterContainer.ts +0 -77
- package/dist/builtin-scenes/Control.d.ts +0 -44
- package/dist/builtin-scenes/Control.js +0 -206
- package/dist/builtin-scenes/Control.scene +0 -3
- package/dist/builtin-scenes/Control.ts +0 -233
- package/dist/builtin-scenes/FlexItem.d.ts +0 -45
- package/dist/builtin-scenes/FlexItem.js +0 -164
- package/dist/builtin-scenes/FlexItem.scene +0 -3
- package/dist/builtin-scenes/FlexItem.ts +0 -180
- package/dist/builtin-scenes/FlexLayout.d.ts +0 -29
- package/dist/builtin-scenes/FlexLayout.js +0 -358
- package/dist/builtin-scenes/FlexLayout.scene +0 -3
- package/dist/builtin-scenes/FlexLayout.ts +0 -409
- package/dist/builtin-scenes/HBoxContainer.d.ts +0 -15
- package/dist/builtin-scenes/HBoxContainer.js +0 -70
- package/dist/builtin-scenes/HBoxContainer.scene +0 -3
- package/dist/builtin-scenes/HBoxContainer.ts +0 -75
- package/dist/builtin-scenes/MarginContainer.d.ts +0 -23
- package/dist/builtin-scenes/MarginContainer.js +0 -131
- package/dist/builtin-scenes/MarginContainer.scene +0 -3
- package/dist/builtin-scenes/MarginContainer.ts +0 -139
- package/dist/builtin-scenes/VBoxContainer.d.ts +0 -15
- package/dist/builtin-scenes/VBoxContainer.js +0 -70
- package/dist/builtin-scenes/VBoxContainer.scene +0 -3
- package/dist/builtin-scenes/VBoxContainer.ts +0 -75
- package/dist/builtin-scenes/controlLayout.d.ts +0 -57
- package/dist/builtin-scenes/controlLayout.js +0 -202
- package/dist/builtin-scenes/controlLayout.ts +0 -270
|
@@ -1,358 +0,0 @@
|
|
|
1
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
-
};
|
|
7
|
-
import { prop, scene, slot } from 'pixifact/compiler';
|
|
8
|
-
import { Control } from './Control.js';
|
|
9
|
-
let FlexLayout = class FlexLayout extends Control {
|
|
10
|
-
#direction = 'row';
|
|
11
|
-
#align = 'start';
|
|
12
|
-
#justify = 'start';
|
|
13
|
-
#gap = 0;
|
|
14
|
-
#paddingX = 0;
|
|
15
|
-
#paddingY = 0;
|
|
16
|
-
#paddingLeft;
|
|
17
|
-
#paddingRight;
|
|
18
|
-
#paddingTop;
|
|
19
|
-
#paddingBottom;
|
|
20
|
-
#baseSizes = new WeakMap();
|
|
21
|
-
get direction() {
|
|
22
|
-
return this.#direction;
|
|
23
|
-
}
|
|
24
|
-
set direction(value) {
|
|
25
|
-
this.#direction = value === 'column' ? 'column' : 'row';
|
|
26
|
-
this.refreshControlLayout();
|
|
27
|
-
}
|
|
28
|
-
get align() {
|
|
29
|
-
return this.#align;
|
|
30
|
-
}
|
|
31
|
-
set align(value) {
|
|
32
|
-
this.#align = parseAlign(value);
|
|
33
|
-
this.layout();
|
|
34
|
-
}
|
|
35
|
-
get justify() {
|
|
36
|
-
return this.#justify;
|
|
37
|
-
}
|
|
38
|
-
set justify(value) {
|
|
39
|
-
this.#justify = parseJustify(value);
|
|
40
|
-
this.layout();
|
|
41
|
-
}
|
|
42
|
-
get gap() {
|
|
43
|
-
return this.#gap;
|
|
44
|
-
}
|
|
45
|
-
set gap(value) {
|
|
46
|
-
this.#gap = Math.max(0, finiteNumber(value, 0));
|
|
47
|
-
this.refreshControlLayout();
|
|
48
|
-
}
|
|
49
|
-
get paddingX() {
|
|
50
|
-
return this.#paddingX;
|
|
51
|
-
}
|
|
52
|
-
set paddingX(value) {
|
|
53
|
-
this.#paddingX = Math.max(0, finiteNumber(value, 0));
|
|
54
|
-
this.refreshControlLayout();
|
|
55
|
-
}
|
|
56
|
-
get paddingY() {
|
|
57
|
-
return this.#paddingY;
|
|
58
|
-
}
|
|
59
|
-
set paddingY(value) {
|
|
60
|
-
this.#paddingY = Math.max(0, finiteNumber(value, 0));
|
|
61
|
-
this.refreshControlLayout();
|
|
62
|
-
}
|
|
63
|
-
get paddingLeft() {
|
|
64
|
-
return this.#paddingLeft ?? this.#paddingX;
|
|
65
|
-
}
|
|
66
|
-
set paddingLeft(value) {
|
|
67
|
-
this.#paddingLeft = Math.max(0, finiteNumber(value, 0));
|
|
68
|
-
this.refreshControlLayout();
|
|
69
|
-
}
|
|
70
|
-
get paddingRight() {
|
|
71
|
-
return this.#paddingRight ?? this.#paddingX;
|
|
72
|
-
}
|
|
73
|
-
set paddingRight(value) {
|
|
74
|
-
this.#paddingRight = Math.max(0, finiteNumber(value, 0));
|
|
75
|
-
this.refreshControlLayout();
|
|
76
|
-
}
|
|
77
|
-
get paddingTop() {
|
|
78
|
-
return this.#paddingTop ?? this.#paddingY;
|
|
79
|
-
}
|
|
80
|
-
set paddingTop(value) {
|
|
81
|
-
this.#paddingTop = Math.max(0, finiteNumber(value, 0));
|
|
82
|
-
this.refreshControlLayout();
|
|
83
|
-
}
|
|
84
|
-
get paddingBottom() {
|
|
85
|
-
return this.#paddingBottom ?? this.#paddingY;
|
|
86
|
-
}
|
|
87
|
-
set paddingBottom(value) {
|
|
88
|
-
this.#paddingBottom = Math.max(0, finiteNumber(value, 0));
|
|
89
|
-
this.refreshControlLayout();
|
|
90
|
-
}
|
|
91
|
-
layout() {
|
|
92
|
-
const children = this.default?.children;
|
|
93
|
-
if (!children || children.length === 0) {
|
|
94
|
-
this.syncControlBoxSize();
|
|
95
|
-
return;
|
|
96
|
-
}
|
|
97
|
-
for (const child of children) {
|
|
98
|
-
this.#rememberBaseSize(child);
|
|
99
|
-
}
|
|
100
|
-
const horizontal = this.#direction === 'row';
|
|
101
|
-
const mainAxis = horizontal ? 'row' : 'column';
|
|
102
|
-
const crossAxis = horizontal ? 'column' : 'row';
|
|
103
|
-
const paddingMainStart = horizontal ? this.paddingLeft : this.paddingTop;
|
|
104
|
-
const paddingMainEnd = horizontal ? this.paddingRight : this.paddingBottom;
|
|
105
|
-
const paddingCrossStart = horizontal ? this.paddingTop : this.paddingLeft;
|
|
106
|
-
const paddingCrossEnd = horizontal ? this.paddingBottom : this.paddingRight;
|
|
107
|
-
const items = children.map((child) => this.#createLayoutItem(child, mainAxis, crossAxis));
|
|
108
|
-
const gapTotal = this.#gap * Math.max(0, items.length - 1);
|
|
109
|
-
const naturalMain = items.reduce((sum, item) => sum + item.baseMain + marginMain(item.props, horizontal), 0);
|
|
110
|
-
const naturalCross = items.reduce((max, item) => Math.max(max, item.baseCross + marginCross(item.props, horizontal)), 0);
|
|
111
|
-
const naturalWidth = horizontal
|
|
112
|
-
? naturalMain + gapTotal + paddingMainStart + paddingMainEnd
|
|
113
|
-
: naturalCross + paddingCrossStart + paddingCrossEnd;
|
|
114
|
-
const naturalHeight = horizontal
|
|
115
|
-
? naturalCross + paddingCrossStart + paddingCrossEnd
|
|
116
|
-
: naturalMain + gapTotal + paddingMainStart + paddingMainEnd;
|
|
117
|
-
const assigned = this.getAssignedControlBoxSize();
|
|
118
|
-
const containerWidth = assigned.width ?? naturalWidth;
|
|
119
|
-
const containerHeight = assigned.height ?? naturalHeight;
|
|
120
|
-
const containerMain = horizontal ? containerWidth : containerHeight;
|
|
121
|
-
const containerCross = horizontal ? containerHeight : containerWidth;
|
|
122
|
-
const innerMain = Math.max(0, containerMain - paddingMainStart - paddingMainEnd - gapTotal);
|
|
123
|
-
const innerCross = Math.max(0, containerCross - paddingCrossStart - paddingCrossEnd);
|
|
124
|
-
const freeMain = innerMain - naturalMain;
|
|
125
|
-
this.#resolveMainSizes(items, freeMain, horizontal);
|
|
126
|
-
this.#resolveCrossSizes(items, innerCross, horizontal);
|
|
127
|
-
this.#placeItems(items, containerMain, paddingMainStart, paddingMainEnd, paddingCrossStart, innerCross, horizontal);
|
|
128
|
-
this.syncControlBoxSize();
|
|
129
|
-
}
|
|
130
|
-
measureControlNaturalSize() {
|
|
131
|
-
const children = this.default?.children;
|
|
132
|
-
if (!children || children.length === 0) {
|
|
133
|
-
return { width: 0, height: 0 };
|
|
134
|
-
}
|
|
135
|
-
const gapTotal = this.#gap * Math.max(0, children.length - 1);
|
|
136
|
-
const sizes = children.map((child) => this.#naturalSize(child));
|
|
137
|
-
if (this.#direction === 'row') {
|
|
138
|
-
return {
|
|
139
|
-
width: this.paddingLeft + this.paddingRight + gapTotal + sizes.reduce((sum, size) => sum + size.width, 0),
|
|
140
|
-
height: this.paddingTop + this.paddingBottom + sizes.reduce((max, size) => Math.max(max, size.height), 0),
|
|
141
|
-
};
|
|
142
|
-
}
|
|
143
|
-
return {
|
|
144
|
-
width: this.paddingLeft + this.paddingRight + sizes.reduce((max, size) => Math.max(max, size.width), 0),
|
|
145
|
-
height: this.paddingTop + this.paddingBottom + gapTotal + sizes.reduce((sum, size) => sum + size.height, 0),
|
|
146
|
-
};
|
|
147
|
-
}
|
|
148
|
-
#createLayoutItem(child, mainAxis, crossAxis) {
|
|
149
|
-
const props = child.getFlexItemLayoutProps?.() ?? defaultItemProps;
|
|
150
|
-
const natural = this.#naturalSize(child);
|
|
151
|
-
const naturalMain = mainAxis === 'row' ? natural.width : natural.height;
|
|
152
|
-
const naturalCross = crossAxis === 'row' ? natural.width : natural.height;
|
|
153
|
-
const minMain = mainAxis === 'row' ? props.minWidth : props.minHeight;
|
|
154
|
-
const maxMain = maxSize(mainAxis === 'row' ? props.maxWidth : props.maxHeight);
|
|
155
|
-
const minCross = crossAxis === 'row' ? props.minWidth : props.minHeight;
|
|
156
|
-
const maxCross = maxSize(crossAxis === 'row' ? props.maxWidth : props.maxHeight);
|
|
157
|
-
const basis = basisSize(props.basis, naturalMain);
|
|
158
|
-
const baseMain = clamp(basis, minMain, maxMain);
|
|
159
|
-
const baseCross = clamp(naturalCross, minCross, maxCross);
|
|
160
|
-
return {
|
|
161
|
-
child,
|
|
162
|
-
props,
|
|
163
|
-
baseMain,
|
|
164
|
-
baseCross,
|
|
165
|
-
mainSize: baseMain,
|
|
166
|
-
crossSize: baseCross,
|
|
167
|
-
};
|
|
168
|
-
}
|
|
169
|
-
#resolveMainSizes(items, freeMain, horizontal) {
|
|
170
|
-
if (freeMain > 0) {
|
|
171
|
-
const totalGrow = items.reduce((sum, item) => sum + item.props.grow, 0);
|
|
172
|
-
if (totalGrow > 0) {
|
|
173
|
-
for (const item of items) {
|
|
174
|
-
item.mainSize = clampMain(item.baseMain + freeMain * (item.props.grow / totalGrow), item.props, horizontal);
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
return;
|
|
178
|
-
}
|
|
179
|
-
if (freeMain < 0) {
|
|
180
|
-
const totalShrink = items.reduce((sum, item) => sum + item.props.shrink * item.baseMain, 0);
|
|
181
|
-
if (totalShrink > 0) {
|
|
182
|
-
for (const item of items) {
|
|
183
|
-
const weighted = item.props.shrink * item.baseMain;
|
|
184
|
-
item.mainSize = clampMain(item.baseMain + freeMain * (weighted / totalShrink), item.props, horizontal);
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
#resolveCrossSizes(items, innerCross, horizontal) {
|
|
190
|
-
for (const item of items) {
|
|
191
|
-
const alignSelf = item.props.alignSelf === 'auto' ? this.#align : item.props.alignSelf;
|
|
192
|
-
if (alignSelf === 'stretch') {
|
|
193
|
-
item.crossSize = clampCross(innerCross - marginCross(item.props, horizontal), item.props, horizontal);
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
#placeItems(items, containerMain, paddingMainStart, paddingMainEnd, paddingCrossStart, innerCross, horizontal) {
|
|
198
|
-
const usedMain = items.reduce((sum, item) => sum + item.mainSize + marginMain(item.props, horizontal), 0);
|
|
199
|
-
const remaining = Math.max(0, containerMain - paddingMainStart - paddingMainEnd - usedMain - this.#gap * Math.max(0, items.length - 1));
|
|
200
|
-
const actualGap = this.#justify === 'space-between' && items.length > 1
|
|
201
|
-
? this.#gap + remaining / (items.length - 1)
|
|
202
|
-
: this.#gap;
|
|
203
|
-
let cursor = paddingMainStart + justifyOffset(this.#justify, remaining);
|
|
204
|
-
for (const item of items) {
|
|
205
|
-
const mainStartMargin = horizontal ? item.props.marginLeft : item.props.marginTop;
|
|
206
|
-
const mainEndMargin = horizontal ? item.props.marginRight : item.props.marginBottom;
|
|
207
|
-
const crossStartMargin = horizontal ? item.props.marginTop : item.props.marginLeft;
|
|
208
|
-
const crossEndMargin = horizontal ? item.props.marginBottom : item.props.marginRight;
|
|
209
|
-
const alignSelf = item.props.alignSelf === 'auto' ? this.#align : item.props.alignSelf;
|
|
210
|
-
const crossFree = Math.max(0, innerCross - item.crossSize - crossStartMargin - crossEndMargin);
|
|
211
|
-
const main = cursor + mainStartMargin;
|
|
212
|
-
const cross = paddingCrossStart + crossStartMargin + alignOffset(alignSelf, crossFree);
|
|
213
|
-
const x = horizontal ? main : cross;
|
|
214
|
-
const y = horizontal ? cross : main;
|
|
215
|
-
const width = horizontal ? item.mainSize : item.crossSize;
|
|
216
|
-
const height = horizontal ? item.crossSize : item.mainSize;
|
|
217
|
-
setChildBox(item.child, x, y, width, height);
|
|
218
|
-
cursor = main + item.mainSize + mainEndMargin + actualGap;
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
#rememberBaseSize(child) {
|
|
222
|
-
if (!this.#baseSizes.has(child)) {
|
|
223
|
-
this.#baseSizes.set(child, {
|
|
224
|
-
width: child.width,
|
|
225
|
-
height: child.height,
|
|
226
|
-
});
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
#naturalSize(child) {
|
|
230
|
-
const measured = child.measureControlNaturalSize?.();
|
|
231
|
-
if (measured) {
|
|
232
|
-
return measured;
|
|
233
|
-
}
|
|
234
|
-
return this.#baseSizes.get(child) ?? { width: child.width, height: child.height };
|
|
235
|
-
}
|
|
236
|
-
};
|
|
237
|
-
__decorate([
|
|
238
|
-
slot()
|
|
239
|
-
], FlexLayout.prototype, "default", void 0);
|
|
240
|
-
__decorate([
|
|
241
|
-
prop({ type: String, default: 'row' })
|
|
242
|
-
], FlexLayout.prototype, "direction", null);
|
|
243
|
-
__decorate([
|
|
244
|
-
prop({ type: String, default: 'start' })
|
|
245
|
-
], FlexLayout.prototype, "align", null);
|
|
246
|
-
__decorate([
|
|
247
|
-
prop({ type: String, default: 'start' })
|
|
248
|
-
], FlexLayout.prototype, "justify", null);
|
|
249
|
-
__decorate([
|
|
250
|
-
prop({ type: Number, default: 0 })
|
|
251
|
-
], FlexLayout.prototype, "gap", null);
|
|
252
|
-
__decorate([
|
|
253
|
-
prop({ type: Number, default: 0 })
|
|
254
|
-
], FlexLayout.prototype, "paddingX", null);
|
|
255
|
-
__decorate([
|
|
256
|
-
prop({ type: Number, default: 0 })
|
|
257
|
-
], FlexLayout.prototype, "paddingY", null);
|
|
258
|
-
__decorate([
|
|
259
|
-
prop({ type: Number })
|
|
260
|
-
], FlexLayout.prototype, "paddingLeft", null);
|
|
261
|
-
__decorate([
|
|
262
|
-
prop({ type: Number })
|
|
263
|
-
], FlexLayout.prototype, "paddingRight", null);
|
|
264
|
-
__decorate([
|
|
265
|
-
prop({ type: Number })
|
|
266
|
-
], FlexLayout.prototype, "paddingTop", null);
|
|
267
|
-
__decorate([
|
|
268
|
-
prop({ type: Number })
|
|
269
|
-
], FlexLayout.prototype, "paddingBottom", null);
|
|
270
|
-
FlexLayout = __decorate([
|
|
271
|
-
scene()
|
|
272
|
-
], FlexLayout);
|
|
273
|
-
export { FlexLayout };
|
|
274
|
-
const defaultItemProps = {
|
|
275
|
-
grow: 0,
|
|
276
|
-
shrink: 1,
|
|
277
|
-
basis: 'auto',
|
|
278
|
-
minWidth: 0,
|
|
279
|
-
minHeight: 0,
|
|
280
|
-
maxWidth: -1,
|
|
281
|
-
maxHeight: -1,
|
|
282
|
-
marginLeft: 0,
|
|
283
|
-
marginRight: 0,
|
|
284
|
-
marginTop: 0,
|
|
285
|
-
marginBottom: 0,
|
|
286
|
-
alignSelf: 'auto',
|
|
287
|
-
};
|
|
288
|
-
function setChildBox(child, x, y, width, height) {
|
|
289
|
-
if (child.setControlLayoutBox) {
|
|
290
|
-
child.setControlLayoutBox(x, y, width, height);
|
|
291
|
-
return;
|
|
292
|
-
}
|
|
293
|
-
child.position.set(x, y);
|
|
294
|
-
child.width = width;
|
|
295
|
-
child.height = height;
|
|
296
|
-
}
|
|
297
|
-
function marginMain(props, horizontal) {
|
|
298
|
-
return horizontal
|
|
299
|
-
? props.marginLeft + props.marginRight
|
|
300
|
-
: props.marginTop + props.marginBottom;
|
|
301
|
-
}
|
|
302
|
-
function marginCross(props, horizontal) {
|
|
303
|
-
return horizontal
|
|
304
|
-
? props.marginTop + props.marginBottom
|
|
305
|
-
: props.marginLeft + props.marginRight;
|
|
306
|
-
}
|
|
307
|
-
function clampMain(value, props, horizontal) {
|
|
308
|
-
return horizontal
|
|
309
|
-
? clamp(value, props.minWidth, maxSize(props.maxWidth))
|
|
310
|
-
: clamp(value, props.minHeight, maxSize(props.maxHeight));
|
|
311
|
-
}
|
|
312
|
-
function clampCross(value, props, horizontal) {
|
|
313
|
-
return horizontal
|
|
314
|
-
? clamp(value, props.minHeight, maxSize(props.maxHeight))
|
|
315
|
-
: clamp(value, props.minWidth, maxSize(props.maxWidth));
|
|
316
|
-
}
|
|
317
|
-
function basisSize(basis, naturalSize) {
|
|
318
|
-
return basis === 'auto' ? naturalSize : basis;
|
|
319
|
-
}
|
|
320
|
-
function maxSize(value) {
|
|
321
|
-
return value >= 0 ? value : Number.POSITIVE_INFINITY;
|
|
322
|
-
}
|
|
323
|
-
function clamp(value, min, max) {
|
|
324
|
-
return Math.min(max, Math.max(min, value));
|
|
325
|
-
}
|
|
326
|
-
function justifyOffset(justify, remaining) {
|
|
327
|
-
if (justify === 'center') {
|
|
328
|
-
return remaining / 2;
|
|
329
|
-
}
|
|
330
|
-
if (justify === 'end') {
|
|
331
|
-
return remaining;
|
|
332
|
-
}
|
|
333
|
-
return 0;
|
|
334
|
-
}
|
|
335
|
-
function alignOffset(align, remaining) {
|
|
336
|
-
if (align === 'center') {
|
|
337
|
-
return remaining / 2;
|
|
338
|
-
}
|
|
339
|
-
if (align === 'end') {
|
|
340
|
-
return remaining;
|
|
341
|
-
}
|
|
342
|
-
return 0;
|
|
343
|
-
}
|
|
344
|
-
function parseAlign(value) {
|
|
345
|
-
if (value === 'center' || value === 'end' || value === 'stretch') {
|
|
346
|
-
return value;
|
|
347
|
-
}
|
|
348
|
-
return 'start';
|
|
349
|
-
}
|
|
350
|
-
function parseJustify(value) {
|
|
351
|
-
if (value === 'center' || value === 'end' || value === 'space-between') {
|
|
352
|
-
return value;
|
|
353
|
-
}
|
|
354
|
-
return 'start';
|
|
355
|
-
}
|
|
356
|
-
function finiteNumber(value, fallback) {
|
|
357
|
-
return Number.isFinite(value) ? value : fallback;
|
|
358
|
-
}
|