diff --git a/dist/mixins/transition.js b/dist/mixins/transition.js index add95750..7e4b613c 100644 --- a/dist/mixins/transition.js +++ b/dist/mixins/transition.js @@ -46,7 +46,9 @@ export function transition(showDefaultValue) { value ? this.enter() : this.leave(); }, enter() { - this.waitEnterEndPromise = new Promise((resolve) => { + if (this.enterFinishedPromise) + return; + this.enterFinishedPromise = new Promise((resolve) => { const { duration, name } = this.data; const classNames = getClassNames(name); const currentDuration = isObj(duration) ? duration.enter : duration; @@ -78,9 +80,9 @@ export function transition(showDefaultValue) { }); }, leave() { - if (!this.waitEnterEndPromise) + if (!this.enterFinishedPromise) return; - this.waitEnterEndPromise.then(() => { + this.enterFinishedPromise.then(() => { if (!this.data.display) { return; } @@ -103,7 +105,10 @@ export function transition(showDefaultValue) { return; } this.transitionEnded = false; - setTimeout(() => this.onTransitionEnd(), currentDuration); + setTimeout(() => { + this.onTransitionEnd(); + this.enterFinishedPromise = null; + }, currentDuration); this.setData({ classes: classNames['leave-to'] }); }); }); diff --git a/lib/mixins/transition.js b/lib/mixins/transition.js index 922900f2..17317040 100644 --- a/lib/mixins/transition.js +++ b/lib/mixins/transition.js @@ -50,7 +50,9 @@ function transition(showDefaultValue) { }, enter: function () { var _this = this; - this.waitEnterEndPromise = new Promise(function (resolve) { + if (this.enterFinishedPromise) + return; + this.enterFinishedPromise = new Promise(function (resolve) { var _a = _this.data, duration = _a.duration, name = _a.name; var classNames = getClassNames(name); var currentDuration = (0, validator_1.isObj)(duration) ? duration.enter : duration; @@ -83,9 +85,9 @@ function transition(showDefaultValue) { }, leave: function () { var _this = this; - if (!this.waitEnterEndPromise) + if (!this.enterFinishedPromise) return; - this.waitEnterEndPromise.then(function () { + this.enterFinishedPromise.then(function () { if (!_this.data.display) { return; } @@ -108,7 +110,10 @@ function transition(showDefaultValue) { return; } _this.transitionEnded = false; - setTimeout(function () { return _this.onTransitionEnd(); }, currentDuration); + setTimeout(function () { + _this.onTransitionEnd(); + _this.enterFinishedPromise = null; + }, currentDuration); _this.setData({ classes: classNames['leave-to'] }); }); });