vue 动画 —— 滚动动画

简介: vue 动画 —— 滚动动画

要点

滚动动画包含两种变化:

(1)位置变化

transform: translate(-100%);

(2)沿z轴(垂直于屏幕方向)旋转

transform: rotate3d(0, 0, 1, -360deg);

完整范例代码

<template>
    <div>
        <button @click="show = true">点我滚入</button>
        <button @click="show = false">点我滚出</button>
        <transition
                enter-active-class="rollIn"
                leave-active-class="rollOut"
        >
            <div v-show="show" class="circle200">滚动动画</div>
        </transition>
    </div>
</template>
<script>
    export default {
        data() {
            return {
                show: false
            }
        },
    }
</script>
<style scoped>
    .circle200 {
        height: 200px;
        width: 200px;
        background: red;
        border-radius: 50%;
        text-align: center;
        line-height: 200px;
    }
 
    /*滚入——从左侧*/
    @keyframes rollIn {
        0% {
            opacity: 0;
            transform: translate(-100%) rotate3d(0, 0, 1, -360deg);
        }
        100% {
            opacity: 1;
        }
    }
 
    /*滚出——从左侧*/
    @keyframes rollOut {
        0% {
            opacity: 1;
        }
        100% {
            opacity: 0;
            transform: translate(-100%) rotate3d(0, 0, 1, -360deg);
        }
    }
 
    /*滚入——从左侧*/
    .rollIn {
        animation: rollIn 1s;
    }
 
    /*滚出——从左侧*/
    .rollOut {
        animation: rollOut 1s;
    }
</style>


目录
相关文章
|
1天前
|
JavaScript
vue 监听 sessionStorage 中值的变化
vue 监听 sessionStorage 中值的变化
9 1
|
1天前
|
JavaScript 索引
Component name “index“ should always be multi-word vue/multi-word-component-names
Component name “index“ should always be multi-word vue/multi-word-component-names
|
1天前
|
JavaScript
vue 创建项目、运行项目、访问项目(vue2版)
vue 创建项目、运行项目、访问项目(vue2版)
6 0
|
1天前
|
JavaScript
|
1天前
|
JavaScript
Vue中data常见的写法:
Vue中data常见的写法:
|
1天前
|
Web App开发 JavaScript
vue报错【解决方案】 [Violation] Added non-passive event listener to a scroll-blocking <some> event.
vue报错【解决方案】 [Violation] Added non-passive event listener to a scroll-blocking <some> event.
5 0
|
1天前
|
JavaScript
vue v-for循环渲染动态ref表单校验的实现技巧
vue v-for循环渲染动态ref表单校验的实现技巧
5 0
|
前端开发 JavaScript
初识 Vue(24)---(Vue 中同时使用过渡和动画)
Vue 中同时使用过渡和动画 在上篇博客 《Vue 中使用 animate.css 库》基础上开始这篇博客 在上篇博客中,完成了 引入 animate.
1221 0
|
前端开发 内存技术
Vue_同时使用过渡和动画
在上一节我们用animate动画库,在刷新页面时没有动画 如何解决第一次就显示动画内容呢? 在transform 上加上appear 和appear-active-class <transition name='fade' appear enter-active-class='animate.
1541 0
|
1天前
|
JavaScript 编译器