javascript - My vuejs animationtransition is lagging on path change. - Stack Overflow

I am using vue and vue-router for my portfolio. I added simple "fade" animation. And my animat

I am using vue and vue-router for my portfolio. I added simple "fade" animation. And my animation is lagging.

My App.vue ponent:

<template>
    <div id="app">
        <Square/>
        <Navbar/>
    </div>
</template>

My Square.vue ponent:

<template>
    <div id="square">
        <transition name="fade">
            <router-view></router-view>
        </transition>
    </div>
</template>
<style>
    .fade-enter-active, .fade-leave-active {
      transition: opacity 0.5s;
    }
    .fade-enter, .fade-leave-to{
      opacity: 0;
    }
 </style>

My routes file:

import Vue from 'vue';
import Router from 'vue-router';
import Hello from './views/Hello.vue';

Vue.use(Router);

export default new Router({
  routes: [
    {
      path: '/',
      name: 'hello',
      ponent: Hello,
    },
    {
      path: '/i-am',
      name: 'I am',
      ponent: () => import( 
'./views/About.vue'),
    },
    {
      path: '/i-use',
      name: 'I use',
      ponent: () => import( 
'./views/Using.vue'),
    },
   ],
});

And I think it is not because of the style of animation. New content renders faster than old ponent destroys.

I am using vue and vue-router for my portfolio. I added simple "fade" animation. And my animation is lagging.

My App.vue ponent:

<template>
    <div id="app">
        <Square/>
        <Navbar/>
    </div>
</template>

My Square.vue ponent:

<template>
    <div id="square">
        <transition name="fade">
            <router-view></router-view>
        </transition>
    </div>
</template>
<style>
    .fade-enter-active, .fade-leave-active {
      transition: opacity 0.5s;
    }
    .fade-enter, .fade-leave-to{
      opacity: 0;
    }
 </style>

My routes file:

import Vue from 'vue';
import Router from 'vue-router';
import Hello from './views/Hello.vue';

Vue.use(Router);

export default new Router({
  routes: [
    {
      path: '/',
      name: 'hello',
      ponent: Hello,
    },
    {
      path: '/i-am',
      name: 'I am',
      ponent: () => import( 
'./views/About.vue'),
    },
    {
      path: '/i-use',
      name: 'I use',
      ponent: () => import( 
'./views/Using.vue'),
    },
   ],
});

And I think it is not because of the style of animation. New content renders faster than old ponent destroys.

Share Improve this question asked Nov 16, 2018 at 1:40 Ulukbek AbylbekovUlukbek Abylbekov 4591 gold badge6 silver badges21 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 6

VueJS Transition Component has this cool props called mode. This will add a smooth effect upon destroying the previous ponent.

<transition name="fade" mode="out-in">
  <!-- ... the buttons ... -->
</transition>

https://v2.vuejs/v2/guide/transitions.html#Transition-Modes

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745606137a4635682.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信