Skip to content

Commit 6bc0e89

Browse files
committed
refactor: refine transitions and implement the move effect naively
1 parent 383d5b3 commit 6bc0e89

File tree

3 files changed

+243
-146
lines changed

3 files changed

+243
-146
lines changed
Lines changed: 84 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -1,151 +1,156 @@
11
@import "../lib.less";
22

33
.@{veui-prefix}-transition {
4-
// 渐隐渐现
5-
&-fade-leave-active {
6-
transition-duration: 100ms;
7-
}
8-
9-
&-fade-enter-active {
4+
// 渐现 fade-in
5+
&-fade-in-enter-active {
106
transition-duration: 200ms;
11-
}
12-
13-
&-fade-leave-active,
14-
&-fade-enter-active {
157
transition-property: opacity;
168
transition-timing-function: linear;
179
}
1810

19-
&-fade-leave-to,
20-
&-fade-enter {
11+
&-fade-in-enter {
2112
opacity: 0;
2213
}
2314

24-
// 放大渐现,缩小渐隐
25-
&-fade-scale-leave-active {
26-
transition-duration: 100ms;
27-
}
28-
29-
&-fade-scale-enter-active {
15+
// 放大渐现 scale-fade-in
16+
&-scale-fade-in-enter-active {
3017
transition-duration: 200ms;
31-
}
32-
33-
&-fade-scale-leave-active,
34-
&-fade-scale-enter-active {
3518
transition-property: opacity, transform;
3619
transition-timing-function: linear;
3720
}
3821

39-
&-fade-scale-leave-to,
40-
&-fade-scale-enter {
22+
&-scale-fade-in-enter {
4123
opacity: 0;
4224
transform: scale3d(0, 0, 1);
4325
}
4426

45-
&-fade-scale-x-leave-active {
46-
transition-duration: 100ms;
27+
// 移入 slide-in
28+
&-slide-in-enter-active {
29+
transition-property: transform;
30+
transition-duration: 200ms;
31+
transition-timing-function: ease-out;
4732
}
4833

49-
&-fade-scale-x-enter-active {
50-
transition-duration: 200ms;
34+
&-slide-in-enter {
35+
transform: translate3d(
36+
var(--dls-transition-translate-from-x, 0),
37+
var(--dls-transition-translate-from-y, 0),
38+
0
39+
);
5140
}
5241

53-
&-fade-scale-x-leave-active,
54-
&-fade-scale-x-enter-active {
42+
// 渐现移入 slide-fade-in
43+
&-slide-fade-in-enter-active {
5544
transition-property: opacity, transform;
45+
transition-duration: 200ms;
5646
transition-timing-function: linear;
5747
}
5848

59-
&-fade-scale-x-leave-to,
60-
&-fade-scale-x-enter {
49+
&-slide-fade-in-enter {
6150
opacity: 0;
62-
transform: scale3d(0, 1, 1);
51+
transform: translate3d(
52+
var(--dls-transition-translate-from-x, 0),
53+
var(--dls-transition-translate-from-y, 0),
54+
0
55+
);
6356
}
6457

65-
&-fade-scale-y-leave-active {
66-
transition-duration: 100ms;
58+
// 渐变移入 slide-scale-fade-in
59+
&-slide-scale-fade-in-enter-active {
60+
transition-property: opacity, transform;
61+
transition-duration: 200ms;
62+
transition-timing-function: linear;
63+
}
64+
65+
&-slide-scale-fade-in-enter {
66+
opacity: 0;
67+
transform: translate3d(
68+
var(--dls-transition-translate-from-x, 0),
69+
var(--dls-transition-translate-from-y, 0),
70+
0
71+
)
72+
scale3d(0, 0, 1);
6773
}
6874

69-
&-fade-scale-y-enter-active {
75+
// 移动 move
76+
&-move {
77+
transition-property: transform;
7078
transition-duration: 200ms;
79+
transform: translate3d(
80+
var(--dls-transition-translate-x, 0),
81+
var(--dls-transition-translate-y, 0),
82+
0
83+
);
7184
}
7285

73-
&-fade-scale-y-leave-active,
74-
&-fade-scale-y-enter-active {
75-
transition-property: opacity, transform;
86+
// 渐隐 fade-out
87+
&-fade-out-leave-active {
88+
transition-duration: 100ms;
89+
transition-property: opacity;
7690
transition-timing-function: linear;
7791
}
7892

79-
&-fade-scale-y-leave-to,
80-
&-fade-scale-y-enter {
93+
&-fade-out-leave-to {
8194
opacity: 0;
82-
transform: scale3d(1, 0, 1);
8395
}
8496

85-
// 移入,移出
86-
&-translate-leave-active {
87-
transition-property: transform;
97+
// 缩小渐隐 scale-fade-out
98+
&-scale-fade-out-leave-active {
8899
transition-duration: 100ms;
89-
transition-timing-function: ease-in;
100+
transition-property: opacity, transform;
101+
transition-timing-function: linear;
102+
}
103+
104+
&-scale-fade-out-leave-to {
105+
opacity: 0;
106+
transform: scale3d(0, 0, 1);
90107
}
91108

92-
&-translate-enter-active {
109+
// 移出 slide-out
110+
&-slide-out-leave-active {
111+
transition-duration: 100ms;
93112
transition-property: transform;
94-
transition-duration: 200ms;
95-
transition-timing-function: ease-out;
113+
transition-timing-function: ease-in;
96114
}
97115

98-
&-translate-enter {
116+
&-slide-out-leave-to {
99117
transform: translate3d(
100-
var(--dls-transition-translate-from-x, 0),
101-
var(--dls-transition-translate-from-y, 0),
118+
var(--dls-transition-translate-to-x, 0),
119+
var(--dls-transition-translate-to-y, 0),
102120
0
103121
);
104122
}
105123

106-
&-translate-leave-to {
124+
// 渐隐移出 slide-fade-out
125+
&-slide-fade-out-leave-active {
126+
transition-duration: 100ms;
127+
transition-property: opacity, transform;
128+
transition-timing-function: ease-in;
129+
}
130+
131+
&-slide-fade-out-leave-to {
132+
opacity: 0;
107133
transform: translate3d(
108134
var(--dls-transition-translate-to-x, 0),
109135
var(--dls-transition-translate-to-y, 0),
110136
0
111137
);
112138
}
113139

114-
&-fade-translate-scale-leave-active {
115-
transition-property: opacity, transform;
140+
// 渐变移出 slide-scale-fade-out
141+
&-slide-scale-fade-out-leave-active {
116142
transition-duration: 100ms;
117-
}
118-
119-
&-fade-translate-scale-enter-active {
120143
transition-property: opacity, transform;
121-
transition-duration: 200ms;
122-
}
123-
124-
&-fade-translate-scale-enter {
125-
transform: translate3d(
126-
var(--dls-transition-translate-from-x, 0),
127-
var(--dls-transition-translate-from-y, 0),
128-
0
129-
)
130-
scale3d(0, 0, 1);
144+
transition-timing-function: ease-in;
131145
}
132146

133-
&-fade-translate-scale-leave-to {
147+
&-slide-scale-fade-out-leave-to {
148+
opacity: 0;
134149
transform: translate3d(
135150
var(--dls-transition-translate-to-x, 0),
136151
var(--dls-transition-translate-to-y, 0),
137152
0
138153
)
139154
scale3d(0, 0, 1);
140155
}
141-
142-
&-move {
143-
transition-property: transform;
144-
transition-duration: 200ms;
145-
transform: translate3d(
146-
var(--dls-transition-translate-x, 0),
147-
var(--dls-transition-translate-y, 0),
148-
0
149-
);
150-
}
151156
}

0 commit comments

Comments
 (0)