From 97391aaa3055a8925336e090ab3ebdba3230ae6c Mon Sep 17 00:00:00 2001 From: acyza <101238421+acyza@users.noreply.github.com> Date: Sat, 11 Feb 2023 22:11:01 +0800 Subject: [PATCH] fix(popover): location update after transition (#11558) * fix(popover): location update * update --- src/popover/index.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/popover/index.js b/src/popover/index.js index 2e174873e..106361a38 100644 --- a/src/popover/index.js +++ b/src/popover/index.js @@ -1,5 +1,5 @@ import { createPopper, offsetModifier } from '@vant/popperjs'; -import { createNamespace } from '../utils'; +import { createNamespace, isServer } from '../utils'; import { BORDER_BOTTOM } from '../utils/constant'; // Mixins @@ -60,6 +60,10 @@ export default createComponent({ beforeDestroy() { if (this.popper) { + if (!isServer) { + window.removeEventListener('animationend', this.updateLocation); + window.removeEventListener('transitionend', this.updateLocation); + } this.popper.destroy(); this.popper = null; } @@ -67,7 +71,7 @@ export default createComponent({ methods: { createPopper() { - return createPopper(this.$refs.wrapper, this.$refs.popover.$el, { + const popper = createPopper(this.$refs.wrapper, this.$refs.popover.$el, { placement: this.placement, modifiers: [ { @@ -85,6 +89,11 @@ export default createComponent({ }, ], }); + if (!isServer) { + window.addEventListener('animationend', this.updateLocation); + window.addEventListener('transitionend', this.updateLocation); + } + return popper; }, updateLocation() {