laya-coreui-es
Version:
laya核心库、ui库es版本,剔除了媒体、TTF等功能。基于 LayaAir-release_2.12.0 修改
56 lines (55 loc) • 1.69 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.VBox = void 0;
const LayoutBox_1 = require("./LayoutBox");
class VBox extends LayoutBox_1.LayoutBox {
constructor() {
super(...arguments);
this.isSortItem = false;
}
set width(value) {
if (this._width != value) {
super.width = value;
this.callLater(this.changeItems);
}
}
get width() {
return super.width;
}
changeItems() {
this._itemChanged = false;
var items = [];
var maxWidth = 0;
for (var i = 0, n = this.numChildren; i < n; i++) {
var item = this.getChildAt(i);
if (item) {
items.push(item);
maxWidth = this._width ? this._width : Math.max(maxWidth, item.width * item.scaleX);
}
}
if (this.isSortItem) {
this.sortItem(items);
}
var top = 0;
for (i = 0, n = items.length; i < n; i++) {
item = items[i];
item.y = top;
top += item.height * item.scaleY + this._space;
if (this._align == VBox.LEFT) {
item.x = 0;
}
else if (this._align == VBox.CENTER) {
item.x = (maxWidth - item.width * item.scaleX) * 0.5;
}
else if (this._align == VBox.RIGHT) {
item.x = maxWidth - item.width * item.scaleX;
}
}
this._sizeChanged();
}
}
exports.VBox = VBox;
VBox.NONE = "none";
VBox.LEFT = "left";
VBox.CENTER = "center";
VBox.RIGHT = "right";