@@ -122,21 +122,23 @@ export default {
122122 // 进入
123123 // el.style.transform = 'translate(0, 0)'
124124 // el.style.transition = 'all 0.4s'
125- el .style .animation = " pageFromRightToCenter 5000ms forwards" ;
125+ el .style .animation = " pageFromRightToCenter 400ms forwards" ;
126126 el .style .zIndex = " 10" ;
127127 el .style .boxShadow = " -3px 0 5px rgba(0, 0, 0, 0.1)" ;
128128 } else if (dir === " slide-right" ) {
129129 // 返回
130130 // el.style.transform = 'translate(0, 0)'
131131 // el.style.transition = 'transform 0.4s'
132- el .style .animation = " pageFromLeftToCenter 5000ms forwards" ;
132+ el .style .animation = " pageFromLeftToCenter 400ms forwards" ;
133133 el .style .zIndex = " 1" ;
134134 } else {
135135 // fade
136+ el .style .animation = " pageFadeIn 400ms forwards" ;
136137 }
138+ // 这里需要设置个定时器,否则消失的界面会立即隐藏掉
137139 setTimeout (() => {
138140 done ();
139- }, 5000 );
141+ }, 400 );
140142 // done()
141143 },
142144 afterEnter : function (el ) {
@@ -185,22 +187,20 @@ export default {
185187 if (dir === " slide-left" ) {
186188 // el.style.transform = 'translate(-100%, 0)'
187189 // el.style.transition = 'all 0.4s'
188- el .style .animation = " pageFromCenterToLeft 5000ms forwards" ;
190+ el .style .animation = " pageFromCenterToLeft 400ms forwards" ;
189191 el .style .zIndex = " 1" ;
190192 } else if (dir === " slide-right" ) {
191193 // 返回
192- // el.style.transform = 'translate(100%, 0)'
193- // el.style.transition = 'all 0.4s'
194- el .style .animation = " pageFromCenterToRight 5000ms forwards" ;
194+ el .style .animation = " pageFromCenterToRight 400ms forwards" ;
195195 el .style .boxShadow = " -3px 0 5px rgba(0, 0, 0, 0.1)" ;
196196 el .style .zIndex = " 10" ;
197197 } else {
198- // fade
198+ // fade out
199+ el .style .animation = " pageFadeOut 400ms forwards" ;
199200 }
200-
201201 setTimeout (() => {
202202 done ();
203- }, 5000 );
203+ }, 400 );
204204 // done()
205205 },
206206 afterLeave : function (el ) {
@@ -324,25 +324,28 @@ export default {
324324};
325325</script >
326326
327- <style lang="less">
328- html ,
329- body {
330- width : 100% ;
331- height : 100% ;
332- }
327+ <style scoped>
333328.vue-route-transition {
334- position : absolute ;
329+ position : relative ;
330+ background-color : #ededed ;
335331 width : 100% ;
336332 height : 100% ;
333+ display : -webkit-box ;
334+ display : -webkit-flex ;
337335 display : flex ;
336+ -webkit-flex-direction : column ;
338337 flex-direction : column ;
339338 overflow : hidden ;
340339 backface-visibility : hidden ;
341340 perspective : 1000 ;
342341}
342+ </style >
343+ 344+ <style >
343345.fade-enter-active {
344- animation : pageFadeIn 5000 ms forwards ;
346+ animation : pageFadeIn 400 ms forwards ;
345347}
348+ /* fade 进入 */
346349@keyframes pageFadeIn {
347350 from {
348351 opacity : 0 ;
@@ -351,29 +354,37 @@ body {
351354 opacity : 1 ;
352355 }
353356}
357+ @keyframes pageFadeOut {
358+ from {
359+ opacity : 1 ;
360+ }
361+ to {
362+ opacity : 0 ;
363+ }
364+ }
354365
355366/* 路由前进,退出*/
356367.slide-left-leave-active {
357- animation : pageFromCenterToLeft 5000 ms forwards ;
368+ animation : pageFromCenterToLeft 400 ms forwards ;
358369 z-index : 1 ;
359370}
360371
361372/* 路由后退,进入*/
362373.slide-right-enter-active {
363- animation : pageFromLeftToCenter 5000 ms forwards ;
374+ animation : pageFromLeftToCenter 400 ms forwards ;
364375 z-index : 1 ;
365376}
366377
367378/* 路由后退,退出*/
368379.slide-right-leave-active {
369- animation : pageFromCenterToRight 5000 ms forwards ;
380+ animation : pageFromCenterToRight 400 ms forwards ;
370381 z-index : 10 ;
371382 box-shadow : -3px 0 5px rgba (0 , 0 , 0 , 0.1 );
372383}
373384
374385/* 路由前进,进入*/
375386.slide-left-enter-active {
376- animation : pageFromRightToCenter 5000 ms forwards ;
387+ animation : pageFromRightToCenter 400 ms forwards ;
377388 z-index : 10 ;
378389 box-shadow : -3px 0 5px rgba (0 , 0 , 0 , 0.1 );
379390}
0 commit comments