fix(Popover): should update location after transition (#11568)

* fix(popover): location update

* fix(popover): update
This commit is contained in:
acyza 2023-02-12 09:52:50 +08:00 committed by GitHub
parent a21833f973
commit 9cbb2f56fa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -17,6 +17,7 @@ import { Instance, createPopper, offsetModifier } from '@vant/popperjs';
import {
pick,
extend,
inBrowser,
truthProp,
numericProp,
unknownProp,
@ -137,6 +138,10 @@ export default defineComponent({
if (!popper) {
popper = createPopperInstance();
if (inBrowser) {
window.addEventListener('animationend', updateLocation);
window.addEventListener('transitionend', updateLocation);
}
} else {
popper.setOptions(getPopoverOptions());
}
@ -217,6 +222,10 @@ export default defineComponent({
onBeforeUnmount(() => {
if (popper) {
if (inBrowser) {
window.removeEventListener('animationend', updateLocation);
window.removeEventListener('transitionend', updateLocation);
}
popper.destroy();
popper = null;
}