vue动画(transition)

发布时间:2024年01月19日

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;
}
?
/* 设置右侧盒子显示/隐藏的动画  */

简单使用

注意: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;
  }
}
?

文章来源:https://blog.csdn.net/m0_74149462/article/details/135703531
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。