From 6558399e8c441a606f9698f1e763efc16b29278b Mon Sep 17 00:00:00 2001 From: Sylar Date: Wed, 31 Aug 2022 10:01:35 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-79286=20=E5=90=8C=E6=AD=A5=E5=88=B0relea?= =?UTF-8?q?se/11.0?= 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; }