vue实现的常见的动画效果

简介: 本篇文章主要实现了 vue 开发中常见的几种动画效果,有需要的可以自取。

本文包括的动画:

  • zoom-in
    • zoom-in-left
    • zoom-in-right
    • zoom-in-top
    • zoom-in-bottom
    • zoom-in-center-x
    • zoom-in-center-y
  • slide
    • slide-left
    • slide-right
    • slide-top
    • slide-bottom

zoom-in-left

.ivy-zoom-in-left-enter-active,
.ivy-zoom-in-left-leave-active {
   
    transition: all 0.3s ease;
}

.ivy-zoom-in-left-enter-from,
.ivy-zoom-in-left-leave-to {
   
    transform-origin: top left;
    opacity: 0;
    transform: scaleX(0.5);
}

.ivy-zoom-in-left-enter-to,
.ivy-zoom-in-left-leave-from {
   
    transform-origin: top left;
    opacity: 1;
    transform: scaleX(1);
}

zoom-in-right

.ivy-zoom-in-right-enter-active,
.ivy-zoom-in-right-leave-active {
   
    transition: all 0.3s ease;
}

.ivy-zoom-in-right-enter-from,
.ivy-zoom-in-right-leave-to {
   
    transform-origin: top right;
    opacity: 0;
    transform: scaleX(0.5);
}

.ivy-zoom-in-right-enter-to,
.ivy-zoom-in-right-leave-from {
   
    transform-origin: top right;
    opacity: 1;
    transform: scaleX(1);
}

zoom-in-top

.ivy-zoom-in-top-enter-active,
.ivy-zoom-in-top-leave-active {
   
    transition: all 0.3s ease;
}

.ivy-zoom-in-top-enter-from,
.ivy-zoom-in-top-leave-to {
   
    transform-origin: top left;
    opacity: 0;
    transform: scaleY(0.5);
}

.ivy-zoom-in-top-enter-to,
.ivy-zoom-in-top-leave-from {
   
    transform-origin: top left;
    opacity: 1;
    transform: scaleY(1);
}

zoom-in-bottom

.ivy-zoom-in-bottom-enter-active,
.ivy-zoom-in-bottom-leave-active {
   
    transition: all 0.3s ease;
}

.ivy-zoom-in-bottom-enter-from,
.ivy-zoom-in-bottom-leave-to {
   
    transform-origin: bottom left;
    opacity: 0;
    transform: scaleY(0.5);
}

.ivy-zoom-in-bottom-enter-to,
.ivy-zoom-in-bottom-leave-from {
   
    transform-origin: bottom left;
    opacity: 1;
    transform: scaleY(1);
}

zoom-in-center-x

.ivy-zoom-in-center-x-enter-active,
.ivy-zoom-in-center-x-leave-active {
   
    transition: all 0.3s ease;
}

.ivy-zoom-in-center-x-enter-from,
.ivy-zoom-in-center-x-leave-to {
   
    transform-origin: center center;
    opacity: 0;
    transform: scaleY(0);
}

.ivy-zoom-in-center-x-enter-to,
.ivy-zoom-in-center-x-leave-from {
   
    transform-origin: center center;
    opacity: 1;
    transform: scaleY(1);
}

zoom-in-center-y

.ivy-zoom-in-center-y-enter-active,
.ivy-zoom-in-center-y-leave-active {
   
    transition: all 0.3s ease;
}

.ivy-zoom-in-center-y-enter-from,
.ivy-zoom-in-center-y-leave-to {
   
    transform-origin: center center;
    opacity: 0;
    transform: scaleX(0);
}

.ivy-zoom-in-center-y-enter-to,
.ivy-zoom-in-center-y-leave-from {
   
    transform-origin: center center;
    opacity: 1;
    transform: scaleX(1);
}

slide-left

.ivy-slide-left-enter-active,
.ivy-slide-left-leave-active {
   
    transition: all 0.3s ease;
}

.ivy-slide-left-enter-from,
.ivy-slide-left-leave-to {
   
    transform-origin: top left;
    opacity: 0;
    transform: translateX(-80%);
}

.ivy-slide-left-enter-to,
.ivy-slide-left-leave-from {
   
    transform-origin: top left;
    opacity: 1;
    transform: translateX(0);
}

slide-right

.ivy-slide-right-enter-active,
.ivy-slide-right-leave-active {
   
    transition: all 0.3s ease;
}

.ivy-slide-right-enter-from,
.ivy-slide-right-leave-to {
   
    transform-origin: top right;
    opacity: 0;
    transform: translateX(80%);
}

.ivy-slide-right-enter-to,
.ivy-slide-right-leave-from {
   
    transform-origin: top right;
    opacity: 1;
    transform: translateX(0);
}

slide-top

.ivy-slide-top-enter-active,
.ivy-slide-top-leave-active {
   
    transition: all 0.3s ease;
}

.ivy-slide-top-enter-from,
.ivy-slide-top-leave-to {
   
    transform-origin: top left;
    opacity: 0;
    transform: translateY(-100%);
}

.ivy-slide-top-enter-to,
.ivy-slide-top-leave-from {
   
    transform-origin: top left;
    opacity: 1;
    transform: translateY(0);
}

slide-bottom

.ivy-slide-bottom-enter-active,
.ivy-slide-bottom-leave-active {
   
    transition: all 0.3s ease;
}

.ivy-slide-bottom-enter-from,
.ivy-slide-bottom-leave-to {
   
    transform-origin: bottom left;
    opacity: 0;
    transform: translateY(100%);
}

.ivy-slide-bottom-enter-to,
.ivy-slide-bottom-leave-from {
   
    transform-origin: bottom left;
    opacity: 1;
    transform: translateY(0);
}

在vue中使用

<template>
    <transition name="ivy-slide-bottom">
        <div v-show="visible"></div>
    </transition>
</template>
<script setup>
import { ref } from "vue";
const visible = ref(false);
</script>
<style>
.ivy-slide-bottom-enter-active,
.ivy-slide-bottom-leave-active {
    transition: all 0.3s ease;
}

.ivy-slide-bottom-enter-from,
.ivy-slide-bottom-leave-to {
    transform-origin: bottom left;
    opacity: 0;
    transform: translateY(100%);
}

.ivy-slide-bottom-enter-to,
.ivy-slide-bottom-leave-from {
    transform-origin: bottom left;
    opacity: 1;
    transform: translateY(0);
}
</style>

查看动画演示

相关文章
|
23天前
|
JavaScript API 开发者
Vue是如何进行组件化的
Vue是如何进行组件化的
|
24天前
|
JavaScript 前端开发 开发者
vue 数据驱动视图
总之,Vue 数据驱动视图是一种先进的理念和技术,它为前端开发带来了巨大的便利和优势。通过理解和应用这一特性,开发者能够构建出更加动态、高效、用户体验良好的前端应用。在不断发展的前端领域中,数据驱动视图将继续发挥重要作用,推动着应用界面的不断创新和进化。
|
26天前
|
JavaScript 前端开发 开发者
vue学习第一章
欢迎来到我的博客!我是瑞雨溪,一名热爱前端的大一学生,专注于JavaScript与Vue,正向全栈进发。博客分享Vue学习心得、命令式与声明式编程对比、列表展示及计数器案例等。关注我,持续更新中!🎉🎉🎉
31 1
vue学习第一章
|
26天前
|
JavaScript 前端开发 索引
vue学习第三章
欢迎来到瑞雨溪的博客,一名热爱JavaScript与Vue的大一学生。本文介绍了Vue中的v-bind指令,包括基本使用、动态绑定class及style等,希望能为你的前端学习之路提供帮助。持续关注,更多精彩内容即将呈现!🎉🎉🎉
24 1
vue学习第三章
|
26天前
|
缓存 JavaScript 前端开发
vue学习第四章
欢迎来到我的博客!我是瑞雨溪,一名热爱JavaScript与Vue的大一学生。本文介绍了Vue中计算属性的基本与复杂使用、setter/getter、与methods的对比及与侦听器的总结。如果你觉得有用,请关注我,将持续更新更多优质内容!🎉🎉🎉
35 1
vue学习第四章
|
23天前
|
JavaScript 前端开发 开发者
Vue是如何劫持响应式对象的
Vue是如何劫持响应式对象的
21 1
|
23天前
|
JavaScript 前端开发 API
介绍一下Vue中的响应式原理
介绍一下Vue中的响应式原理
27 1
|
26天前
|
JavaScript 前端开发
vue学习第五章
欢迎来到我的博客,我是瑞雨溪,一名热爱JavaScript和Vue的大一学生。自学前端2年半,正向全栈进发。如果你从我的文章中受益,欢迎关注,我将持续分享更多优质内容。你的支持是我最大的动力!🎉🎉🎉
26 1
|
23天前
|
JavaScript 前端开发 开发者
Vue是如何进行组件化的
Vue是如何进行组件化的
|
23天前
|
存储 JavaScript 前端开发
介绍一下Vue的核心功能
介绍一下Vue的核心功能