首页 > 其他分享 >vue动画(transition)

vue动画(transition)

时间:2024-08-05 11:08:51浏览次数:11  
标签:动画 vue transition transform leave fade enter active

Vue动画(transition)

动画列表(选择其中一个即可)

/* fade */
.fade-enter-active,
.fade-leave-active {
  transition: opacity 0.28s;
}

.fade-enter,
.fade-leave-active {
  opacity: 0;
}
/* fade */

/* fade-transform */
.fade-transform-leave-active,
.fade-transform-enter-active {
  transition: all .5s;
}

.fade-transform-enter {
  opacity: 0;
  transform: translateX(-30px);
}

.fade-transform-leave-to {
  opacity: 0;
  transform: translateX(30px);
}
/* fade-transform */

/* breadcrumb */
.breadcrumb-enter-active,
.breadcrumb-leave-active {
  transition: all .5s;
}

.breadcrumb-enter,
.breadcrumb-leave-active {
  opacity: 0;
  transform: translateX(20px);
}

.breadcrumb-move {
  transition: all .5s;
}

.breadcrumb-leave-active {
  position: absolute;
}
/* breadcrumb */

/* page-transition */
.page-transition-enter,
.page-transition-leave-to {
  opacity: 0;
  transform: scale(.5, 1);
}

.page-transition-enter-active {
  transition: all 0.1s ease;
}

.page-transition-leave-active {
  transition: all 0.2s ease;
}
/* page-transition */

/* collapseTransition */
// <collapseTransition>
// </collapseTransition>
/* collapseTransition */

/* sidebarLogoFade */
.sidebarLogoFade-enter-active {
  transition: opacity 1.5s;
}

.sidebarLogoFade-enter,
.sidebarLogoFade-leave-to {
  opacity: 0;
}
/* sidebarLogoFade */

/* 设置左侧盒子显示/隐藏的动画  leftCompTransition */
.leftCompTransition-enter {
  opacity: 1;
  transform: translateX(-100%);
}

.leftCompTransition-leave-to {
  opacity: 1;
  transform: translateX(-480px);
  // 解决页面从上往下位移问题
  position: absolute;
}

.leftCompTransition-enter-active,
.leftCompTransition-leave-active {
  transition: all 0.5s ease;
}

/* 设置左侧盒子显示/隐藏的动画  */

/* 设置右侧盒子显示/隐藏的动画  rightCompTransition */
.rightCompTransition-enter {
  opacity: 1;
  transform: translateX(480px);
}

.rightCompTransition-leave-to {
  opacity: 1;
  transform: translateX(480px);
  // 解决页面从上往下位移问题
  position: absolute;
}

.rightCompTransition-enter-active,
.rightCompTransition-leave-active {
  transition: all 0.5s ease;
}

/* 设置右侧盒子显示/隐藏的动画  */


// background: radial-gradient(#43cbc3, transparent); // 渐变

简单使用

注意:transition 需配合 v-if / v-show使用

    <transition name="leftCompTransition" mode="out-in">
      <div class="choose-box" v-if="isShowBox"></div>
    </transition>

完整使用(案例)

    <transition name="leftCompTransition" mode="out-in">
      <div class="choose-box" v-if="isShowBox">外面的大盒子</div>
    </transition>

    <div :class="[isShowBox ? 'folding-box-show' : 'folding-box-hide', 'folding-box']"
         :title="isShowBox ? '收起' : '展开'"
         @click="changeIsShowBox"
    >
      <i :class="isShowBox ? 'el-icon-arrow-left' : 'el-icon-arrow-right'"></i>
    </div>


      isShowBox: true,
   
	changeIsShowBox() {
      this.isShowBox = !this.isShowBox;
    }





.choose-box {
  width: 500px;
  background-color: #ffffff;
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 999 !important;
  box-shadow: 4px 0px 8px 0px rgba(0, 0, 0, 0.1), inset -1px 0px 0px 0px #eeeeee;
  border-radius: 4px;
}


.folding-box {
  z-index: 999 !important;
  width: 16px;
  height: 72px;
  background: #59AAF5;
  border-radius: 0 36px 36px 0;
  position: absolute;
  top: 0;
  bottom: 0;
  margin: auto 0;
  color: #FFFFFF;
  text-align: center;
  line-height: 72px;
  cursor: pointer;
  transition: left 0.5s ease;

  &-show {
    left: 502px;
  }

  &-hide {
    left: 0px;
  }
}

标签:动画,vue,transition,transform,leave,fade,enter,active
From: https://www.cnblogs.com/ProgrammerMao-001/p/18342778

相关文章