Skip to content

Commit a33e26f

Browse files
committed
fix: fixed popup animation v-if bug
1 parent cb7f514 commit a33e26f

File tree

2 files changed

+60
-39
lines changed

2 files changed

+60
-39
lines changed

src/popup/src/popup.vue

+41-28
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,3 @@
1-
<template lang="html">
2-
<transition v-if="currentVisible">
3-
<div
4-
:class='{
5-
[`${prefixCls}`]: true,
6-
[`${prefixCls}--hidden`]: !maskVisible,
7-
}'
8-
>
9-
<div :class='{
10-
[`${prefixCls}__wrapper`]: true,
11-
[`${prefixCls}__wrapper-${direction}`]: true,
12-
}'
13-
:style='transitionDurationStyle'
14-
>
15-
<slot></slot>
16-
</div>
17-
<za-mask
18-
v-if="hasMask"
19-
:class='[`fade-${animationState}`]'
20-
:style='animationDurationStyle'
21-
:visible='maskVisible'
22-
:type='maskType'
23-
@click="onMaskClick"/>
24-
</div>
25-
</transition>
26-
</template>
27-
281
<script>
292
import zaMask from '../../mask';
303
import getContainer from '../../mixins/get-container';
@@ -119,7 +92,7 @@ export default {
11992
this.animationState = 'enter';
12093
this.timerEnter = setTimeout(() => {
12194
this.maskVisible = true;
122-
});
95+
}, 10);
12396
},
12497
leave() {
12598
this.animationState = 'leave';
@@ -148,5 +121,45 @@ export default {
148121
beforeDestroy() {
149122
this.removeTimer();
150123
},
124+
render() {
125+
const {
126+
prefixCls,
127+
hasMask,
128+
direction,
129+
maskType,
130+
onMaskClick,
131+
maskVisible,
132+
currentVisible,
133+
animationState,
134+
transitionDurationStyle,
135+
animationDurationStyle,
136+
} = this;
137+
const popupCls = maskVisible ? `${prefixCls} ${prefixCls}--opened` : `${prefixCls}`;
138+
return (
139+
<transition>
140+
{currentVisible ?
141+
<div
142+
class={`${popupCls}`}
143+
>
144+
<div class={`${prefixCls}__wrapper ${prefixCls}__wrapper-${direction}`}
145+
style={transitionDurationStyle}
146+
>
147+
{this.$slots.default}
148+
</div>
149+
{
150+
hasMask ?
151+
<za-mask
152+
class={`fade-${animationState}`}
153+
style={animationDurationStyle}
154+
visible={maskVisible}
155+
type={maskType}
156+
onClick={onMaskClick} />
157+
: null
158+
}
159+
</div> : null
160+
}
161+
</transition>
162+
);
163+
},
151164
};
152165
</script>

src/popup/style/component.scss

+19-11
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33

44
@include e(wrapper) {
55
position: fixed;
6-
transform: translate(0, 0);
7-
transition-property: transform;
86
overflow: auto;
97
-webkit-overflow-scrolling: touch;
108
z-index: $zIndex-popup;
@@ -13,57 +11,67 @@
1311
left: 0;
1412
bottom: 0;
1513
width: 100%;
14+
transform: translate(0, 100%);
1615
}
1716

1817
&-top {
1918
left: 0;
2019
top: 0;
2120
width: 100%;
21+
transform: translate(0, -100%);
2222
}
2323

2424
&-left {
2525
left: 0;
2626
top: 0;
2727
height: 100%;
28+
transform: translate(-100%, 0);
2829
}
2930

3031
&-right {
3132
right: 0;
3233
top: 0;
3334
height: 100%;
35+
transform: translate(100%, 0);
3436
}
3537

3638
&-center {
39+
display: none;
3740
top: 0;
3841
right: 0;
3942
bottom: 0;
4043
left: 0;
41-
display: flex;
42-
justify-content: center;
43-
align-items: center;
4444
}
4545
}
4646

47-
@include m(hidden) {
47+
@include m(opened) {
4848
@include e(wrapper) {
4949
&-bottom {
50-
transform: translate(0, 100%);
50+
transform: translate(0, 0);
51+
transition-property: transform;
5152
}
5253

5354
&-top {
54-
transform: translate(0, -100%);
55+
transform: translate(0, 0);
56+
transition-property: transform;
5557
}
5658

5759
&-left {
58-
transform: translate(-100%, 0);
60+
transform: translate(0, 0);
61+
transition-property: transform;
5962
}
6063

6164
&-right {
62-
transform: translate(100%, 0);
65+
transform: translate(0, 0);
66+
transition-property: transform;
6367
}
6468

6569
&-center {
66-
display: none;
70+
display: flex;
71+
justify-content: center;
72+
align-items: center;
73+
transform: translate(0, 0);
74+
transition-property: transform;
6775
}
6876
}
6977
}

0 commit comments

Comments
 (0)