From 6de63615f713d43e084bef97b54f67f2b7283cb9 Mon Sep 17 00:00:00 2001 From: zsmj Date: Tue, 30 Aug 2022 16:39:26 +0800 Subject: [PATCH] =?UTF-8?q?KERNEL-12552=20&&=20REPORT-79374=20fix:=20=20?= =?UTF-8?q?=E4=B8=8D=E6=89=A7=E8=A1=8CBI.init()=EF=BC=8C=E5=BE=88=E5=A4=9A?= =?UTF-8?q?=E6=96=B9=E6=B3=95=E8=B0=83=E7=94=A8=E4=BC=9A=E5=87=BA=E7=8E=B0?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/core/controller/controller.layer.js | 6 +++++- src/core/controller/controller.resizer.js | 17 ++++++++++------- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/core/controller/controller.layer.js b/src/core/controller/controller.layer.js index 98470c5a9..6887603f7 100644 --- a/src/core/controller/controller.layer.js +++ b/src/core/controller/controller.layer.js @@ -15,7 +15,10 @@ BI.LayerController = BI.inherit(BI.Controller, { this.layerManager = {}; this.layouts = {}; this.zindex = BI.zIndex_layer; - BI.Resizers.add("layerController" + BI.uniqueId(), BI.bind(this._resize, this)); + }, + + _initResizer: function () { + this.resizer = BI.Resizers.add("layerController" + BI.uniqueId(), BI.bind(this._resize, this)); }, _resize: function () { @@ -38,6 +41,7 @@ BI.LayerController = BI.inherit(BI.Controller, { }, create: function (name, from, op, context) { + BI.isNull(this.resizer) && this._initResizer(); if (this.has(name)) { return this.get(name); } diff --git a/src/core/controller/controller.resizer.js b/src/core/controller/controller.resizer.js index a471cebdf..900bd3927 100644 --- a/src/core/controller/controller.resizer.js +++ b/src/core/controller/controller.resizer.js @@ -5,18 +5,20 @@ * @class */ BI.ResizeController = BI.inherit(BI.Controller, { + init: function () { - var self = this; this.resizerManger = {}; - var fn = BI.debounce(function (ev) { - // if (BI.isWindow(ev.target)) { + }, + + _initResizeListener: function () { + var self = this; + this.resizeHandler = BI.debounce(function (ev) { self._resize(ev); - // } }, 30); if ("onorientationchange" in _global) { - _global.onorientationchange = fn; + _global.onorientationchange = this.resizeHandler; } else { - BI.Widget._renderEngine.createElement(_global).resize(fn); + BI.Widget._renderEngine.createElement(_global).resize(this.resizeHandler); } }, @@ -34,13 +36,14 @@ BI.ResizeController = BI.inherit(BI.Controller, { } if (BI.isFunction(resizer)) { resizer(ev); - return; } }); }, add: function (name, resizer) { var self = this; + BI.isNull(this.resizeHandler) && this._initResizeListener(); + if (this.has(name)) { return this; }