首页 > 其他分享 >vue实现的常见的动画效果

vue实现的常见的动画效果

时间:2023-04-23 12:31:57浏览次数:36  
标签:动画 vue 常见 zoom transform leave slide enter ivy

本文包括的动画:

  • 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>

查看动画演示



标签:动画,vue,常见,zoom,transform,leave,slide,enter,ivy
From: https://blog.51cto.com/jikun/6217064

相关文章

  • 可视化大屏的终极解决方案居然这么简单,vue-autofit一行全搞定!
    可视化大屏适配/自适应现状可视化大屏的适配是一个老生常谈的话题了,现在其实不乏一些大佬开源的自适应插件、工具但是我为什么还要重复造轮子呢?因为目前市面上适配工具每一个都无法做到完美的效果,做出来的东西都差不多,最终实现效果都逃不出白边的手掌心,可以解决白边问题的,要么太......
  • vue3 create-vue 开启vite自动验证eslint
    0.vue3 cli推荐新的构建工具vite,但没有yarnrundev后并不自动检测eslint规则,需要运行yarnruneslint1.添加组件即可 yarnadd vite-plugin-eslint--dev 2.在vite.config.js加入1import{fileURLToPath,URL}from'node:url'23import{defineConfig}......
  • 前端必须学会的vueh5布局瀑布流 简易通俗易懂 左右排版
    css简易版瀑布流布局通过v-if="index%2===0"v-if="index%2===1"进行判断显示左边右边左右瀑布流排版,在每一列中交替地排放元素。具体来说,可以通过对每一列进行编号,然后对奇数列和偶数列分别设置不同的样式来实现左右瀑布流排版。html<div><cl-pull-refreshv-model="isR......
  • ant design of vue的a-rang-picker时间控制既不能选今天以后的日期且开始时间跟结束时
    在项目中这个问题在困扰我,虽然我知道它是有一个Api是disableDate来控制时间的选择;但是只能够实现开始时间跟结束时间之间差不能超过3天。效果图接下来就是代码时间呀<a-col><a-form-model-itemlabel="任务时间范围"prop="priceRangeDate"><a-range-picker......
  • vue3 keep-alive实现tab页面缓存
    先上图 如何在我们切换tab标签的时候,缓存标签最后操作的内容,简单来说就是每个标签页中设置的比如搜索条件及结果、分页、新增、编辑等数据在切换回来的时候还能保持原样。看看keep-alive是如何实现该功能的。首先我们要了解keep-alive的基本使用。具体介绍请查看官方文档(htt......
  • vue 3.0 对应node 版本
    npmrundev我的版本v14.16.116.19.016.18.1node多版本管理工具https://blog.csdn.net/weixin_57844432/article/details/127788884failedtoloadconfigfromD:\ProFolder\hczhyq\slkj_custom_front\vite.config.tserrorwhenstartingdevserver:Error:Cannotfind......
  • vue 拖拽功能实现
    前言最新项目里使用到了拖拽的功能,查阅资料后,看到一篇关于拖拽的详细文章:https://www.cnblogs.com/xiaohuochai/p/5886618.html基于此,记录下vue实现拖拽的过程,以下是编写的示例demo效果图:设置拖拽时,需要拖拽的元素要设置draggable=true及元素是否可拖动。默认是draggab......
  • Vue设置默认加载页面,去掉地址栏#号
     {path:'/',component:Login,//想默认启动的页面},mode:"history"//去掉地址栏的#号 ......
  • 解决vue2.0路由 TypeError: Cannot read property 'matched' of undefined 的错误问题
      找了很久这个问题 解决vue2.0路由TypeError:Cannotreadproperty'matched'ofundefined的错误问题-北桥苏-博客园(cnblogs.com)  解决办法改为   问题解决  没有找到为什么 好像高版本的router没有这个问题 我因为需要降级到了3.1.3 ......
  • Vue Typescript 引入文件接口,就无法使用withDefaults
    就是代码写的不规范报错写法 import{Setting}from'@element-plus/icons-vue' import{defineProps,withDefaults}from'vue' import{PiProject}from'@/types/Project' interfaceProjectCardProps{ project:PiProject } constprops=de......