From 4128a9360bf46958228d923e63fc00c1af620e73 Mon Sep 17 00:00:00 2001 From: guy Date: Sun, 9 Jan 2022 14:16:18 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E5=8A=A8=E7=94=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/case/combo/bubblecombo/combo.bubble.js | 4 +- src/core/4.widget.js | 49 +++++++++++++++++++++- 2 files changed, 51 insertions(+), 2 deletions(-) diff --git a/src/case/combo/bubblecombo/combo.bubble.js b/src/case/combo/bubblecombo/combo.bubble.js index 5cedb9b5d..9b26306df 100644 --- a/src/case/combo/bubblecombo/combo.bubble.js +++ b/src/case/combo/bubblecombo/combo.bubble.js @@ -55,8 +55,10 @@ BI.BubbleCombo = BI.inherit(BI.Widget, { el: o.el, popup: BI.extend({ type: "bi.bubble_popup_view", + animation: "bi-zoom-big", + animationDuring: 300, }, o.popup, { - cls: (o.popup.cls || "") + " bi-zoom-big-enter bi-zoom-big-enter-active" + // cls: (o.popup.cls || "") + " bi-zoom-big-enter bi-zoom-big-enter-active" }) }); this.combo.on(BI.Combo.EVENT_TRIGGER_CHANGE, function () { diff --git a/src/core/4.widget.js b/src/core/4.widget.js index 5d420df20..7d551eae9 100644 --- a/src/core/4.widget.js +++ b/src/core/4.widget.js @@ -7,6 +7,15 @@ */ !(function () { + var cancelAnimationFrame = + _global.cancelAnimationFrame || + _global.webkitCancelAnimationFrame || + _global.mozCancelAnimationFrame || + _global.oCancelAnimationFrame || + _global.msCancelAnimationFrame || + _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]; @@ -34,6 +43,8 @@ tag: null, disabled: false, invisible: false, + animation: "", + animationDuring: 0, invalid: false, baseCls: "", extraCls: "", @@ -467,13 +478,49 @@ }, setVisible: function (visible) { + var self = this, o = this.options; + var lastVisible = !o.invisible; this._setVisible(visible); if (visible === true) { // 用this.element.show()会把display属性改成block this.element.css("display", ""); this._mount(); + if (o.animation && !lastVisible) { + this.element.removeClass(o.animation + "-leave").removeClass(o.animation + "-leave-active").addClass(o.animation + "-enter"); + if (this._requestAnimationFrame) { + cancelAnimationFrame(this._requestAnimationFrame); + } + this._requestAnimationFrame = function () { + self.element.addClass(o.animation + "-enter-active"); + }; + requestAnimationFrame(this._requestAnimationFrame); + if (this._animationDuring){ + clearTimeout(this._animationDuring); + } + this._animationDuring = setTimeout(function () { + self.element.removeClass(o.animation + "-enter").removeClass(o.animation + "-enter-active"); + }, o.animationDuring); + } } else if (visible === false) { - this.element.css("display", "none"); + if (o.animation && lastVisible) { + this.element.removeClass(o.animation + "-enter").removeClass(o.animation + "-enter-active").addClass(o.animation + "-leave"); + if (this._requestAnimationFrame) { + cancelAnimationFrame(this._requestAnimationFrame); + } + this._requestAnimationFrame = function () { + self.element.addClass(o.animation + "-leave-active"); + }; + requestAnimationFrame(this._requestAnimationFrame); + if (this._animationDuring){ + clearTimeout(this._animationDuring); + } + this._animationDuring = setTimeout(function () { + self.element.removeClass(o.animation + "-leave").removeClass(o.animation + "-leave-active"); + self.element.css("display", "none"); + }, o.animationDuring); + } else { + this.element.css("display", "none"); + } } this.fireEvent(BI.Events.VIEW, visible); }, From e8480f910b566adf548e20ebdde31c813da9296e Mon Sep 17 00:00:00 2001 From: guy Date: Sun, 9 Jan 2022 14:16:36 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E5=8A=A8=E7=94=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/case/combo/bubblecombo/combo.bubble.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/case/combo/bubblecombo/combo.bubble.js b/src/case/combo/bubblecombo/combo.bubble.js index 9b26306df..8f4dc80d5 100644 --- a/src/case/combo/bubblecombo/combo.bubble.js +++ b/src/case/combo/bubblecombo/combo.bubble.js @@ -57,9 +57,7 @@ BI.BubbleCombo = BI.inherit(BI.Widget, { type: "bi.bubble_popup_view", animation: "bi-zoom-big", animationDuring: 300, - }, o.popup, { - // cls: (o.popup.cls || "") + " bi-zoom-big-enter bi-zoom-big-enter-active" - }) + }, o.popup) }); this.combo.on(BI.Combo.EVENT_TRIGGER_CHANGE, function () { self.fireEvent(BI.BubbleCombo.EVENT_TRIGGER_CHANGE, arguments);