UNPKG

laya-coreui-es

Version:

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

44 lines (43 loc) 1.2 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ScaleBox = void 0; const Box_1 = require("./Box"); const ILaya_1 = require("../../ILaya"); class ScaleBox extends Box_1.Box { constructor() { super(...arguments); this._oldW = 0; this._oldH = 0; } onEnable() { ILaya_1.ILaya.stage.on("resize", this, this.onResize); this.onResize(); } onDisable() { ILaya_1.ILaya.stage.off("resize", this, this.onResize); } onResize() { let stage = ILaya_1.ILaya.stage; if (this.width > 0 && this.height > 0) { var scale = Math.min(stage.width / this._oldW, stage.height / this._oldH); super.width = stage.width; super.height = stage.height; this.scale(scale, scale); } } set width(value) { super.width = value; this._oldW = value; } get width() { return super.width; } set height(value) { super.height = value; this._oldH = value; } get height() { return super.height; } } exports.ScaleBox = ScaleBox;