UNPKG

laya-coreui-es

Version:

laya核心库、ui库es版本,剔除了媒体、TTF等功能。基于 LayaAir-release_2.12.0 修改

52 lines (51 loc) 1.56 kB
import { LayoutBox } from "./LayoutBox"; export class VBox extends 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(); } } VBox.NONE = "none"; VBox.LEFT = "left"; VBox.CENTER = "center"; VBox.RIGHT = "right";