fix: drawer throw error when unmounted
parent
c1102df3f0
commit
848d6497e6
|
@ -242,7 +242,7 @@ const Drawer = defineComponent({
|
|||
const { placement, levelMove, duration, ease, getContainer } = this.$props;
|
||||
if (!windowIsUndefined) {
|
||||
this.levelDom.forEach(dom => {
|
||||
if (this.isOpenChange || openTransition) {
|
||||
if (dom && (this.isOpenChange || openTransition)) {
|
||||
/* eslint no-param-reassign: "error" */
|
||||
dom.style.transition = `transform ${duration} ${ease}`;
|
||||
addEventListener(dom, transitionEnd, this.trnasitionEnd);
|
||||
|
@ -275,6 +275,8 @@ const Drawer = defineComponent({
|
|||
if (right) {
|
||||
document.body.style.position = 'relative';
|
||||
document.body.style.width = `calc(100% - ${right}px)`;
|
||||
clearTimeout(this.timeout);
|
||||
if (this.dom) {
|
||||
this.dom.style.transition = 'none';
|
||||
switch (placement) {
|
||||
case 'right':
|
||||
|
@ -289,7 +291,6 @@ const Drawer = defineComponent({
|
|||
default:
|
||||
break;
|
||||
}
|
||||
clearTimeout(this.timeout);
|
||||
this.timeout = setTimeout(() => {
|
||||
this.dom.style.transition = `${trannsformTransition},${widthTransition}`;
|
||||
this.dom.style.width = '';
|
||||
|
@ -297,6 +298,7 @@ const Drawer = defineComponent({
|
|||
this.dom.style.msTransform = '';
|
||||
});
|
||||
}
|
||||
}
|
||||
// 手机禁滚
|
||||
domArray.forEach((item, i) => {
|
||||
if (!item) {
|
||||
|
@ -317,6 +319,12 @@ const Drawer = defineComponent({
|
|||
if (transitionStr) {
|
||||
document.body.style.overflowX = 'hidden';
|
||||
}
|
||||
if (placement === 'right' && this.maskDom) {
|
||||
this.maskDom.style.left = `-${right}px`;
|
||||
this.maskDom.style.width = `calc(100% + ${right}px)`;
|
||||
}
|
||||
clearTimeout(this.timeout);
|
||||
if (this.dom) {
|
||||
this.dom.style.transition = 'none';
|
||||
let heightTransition;
|
||||
switch (placement) {
|
||||
|
@ -325,10 +333,6 @@ const Drawer = defineComponent({
|
|||
this.dom.style.msTransform = `translateX(${right}px)`;
|
||||
this.dom.style.width = '100%';
|
||||
widthTransition = `width 0s ${ease} ${duration}`;
|
||||
if (this.maskDom) {
|
||||
this.maskDom.style.left = `-${right}px`;
|
||||
this.maskDom.style.width = `calc(100% + ${right}px)`;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 'top':
|
||||
|
@ -342,7 +346,6 @@ const Drawer = defineComponent({
|
|||
default:
|
||||
break;
|
||||
}
|
||||
clearTimeout(this.timeout);
|
||||
this.timeout = setTimeout(() => {
|
||||
this.dom.style.transition = `${trannsformTransition},${
|
||||
heightTransition ? `${heightTransition},` : ''
|
||||
|
@ -353,6 +356,7 @@ const Drawer = defineComponent({
|
|||
this.dom.style.height = '';
|
||||
});
|
||||
}
|
||||
}
|
||||
domArray.forEach((item, i) => {
|
||||
if (!item) {
|
||||
return;
|
||||
|
|
Loading…
Reference in New Issue