From 6aa3895895cfc358ba1cdcc29234c44609556b01 Mon Sep 17 00:00:00 2001 From: guy Date: Sun, 16 Jan 2022 15:14:27 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20=E6=95=B4=E7=90=86=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/core/4.widget.js | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/core/4.widget.js b/src/core/4.widget.js index 7d551eae9..245a2491b 100644 --- a/src/core/4.widget.js +++ b/src/core/4.widget.js @@ -16,6 +16,7 @@ _global.clearTimeout; var requestAnimationFrame = _global.requestAnimationFrame || _global.webkitRequestAnimationFrame || _global.mozRequestAnimationFrame || _global.oRequestAnimationFrame || _global.msRequestAnimationFrame || _global.setTimeout; + function callLifeHook (self, life) { var hooks = [], hook; hook = self[life]; @@ -477,7 +478,7 @@ } }, - setVisible: function (visible) { + _innerSetVisible: function (visible) { var self = this, o = this.options; var lastVisible = !o.invisible; this._setVisible(visible); @@ -494,7 +495,7 @@ self.element.addClass(o.animation + "-enter-active"); }; requestAnimationFrame(this._requestAnimationFrame); - if (this._animationDuring){ + if (this._animationDuring) { clearTimeout(this._animationDuring); } this._animationDuring = setTimeout(function () { @@ -511,7 +512,7 @@ self.element.addClass(o.animation + "-leave-active"); }; requestAnimationFrame(this._requestAnimationFrame); - if (this._animationDuring){ + if (this._animationDuring) { clearTimeout(this._animationDuring); } this._animationDuring = setTimeout(function () { @@ -522,6 +523,10 @@ this.element.css("display", "none"); } } + }, + + setVisible: function (visible) { + this._innerSetVisible(visible); this.fireEvent(BI.Events.VIEW, visible); }, @@ -753,8 +758,16 @@ }, destroy: function () { + var self = this, o = this.options; this.__d(); - this.element.destroy(); + if (o.animation) { + this._innerSetVisible(false); + setTimeout(function () { + self.element.destroy(); + }, o.animationDuring); + } else { + this.element.destroy(); + } this.fireEvent(BI.Events.UNMOUNT); this.fireEvent(BI.Events.DESTROY); this._purgeRef();