fix(Popup): should watch lockScroll (#8169)

* fix(Popup): should watch lockScroll

* chore: oreder

* chore: upd

* chore: upd
This commit is contained in:
neverland
2021-02-16 16:22:34 +08:00
committed by GitHub
parent f7b09d1677
commit 86b276caa5
2 changed files with 38 additions and 30 deletions
+2 -14
View File
@@ -11,7 +11,6 @@ import {
CSSProperties,
TeleportProps,
onDeactivated,
onBeforeUnmount,
} from 'vue';
import { createNamespace, isDef, UnknownProp } from '../utils';
@@ -116,11 +115,6 @@ export default createComponent({
const zIndex = ref<number>();
const popupRef = ref<HTMLElement>();
const [lockScroll, unlockScroll] = useLockScroll(
popupRef,
() => props.lockScroll
);
const lazyRender = useLazyRender(() => props.show || !props.lazyRender);
const style = computed(() => {
@@ -146,7 +140,6 @@ export default createComponent({
}
opened = true;
lockScroll();
zIndex.value = ++globalZIndex;
}
};
@@ -154,7 +147,6 @@ export default createComponent({
const close = () => {
if (opened) {
opened = false;
unlockScroll();
emit('update:show', false);
}
};
@@ -258,6 +250,8 @@ export default createComponent({
useExpose({ popupRef });
useLockScroll(popupRef, () => props.show && props.lockScroll);
useEventListener('popstate', () => {
if (props.closeOnPopstate) {
close();
@@ -285,12 +279,6 @@ export default createComponent({
}
});
onBeforeUnmount(() => {
if (opened) {
unlockScroll();
}
});
return () => {
if (props.teleport) {
return (