zoukankan      html  css  js  c++  java
  • Vue中的列表item依次进入动画

    <template>
        <div class="my-class">
            <div class="title">
                我的班级
            </div>
            <div class="all-class" v-if="!HasNoClass">
                <el-row :gutter="17">
                    <transition-group appear tag="el-col" @beforeEnter="beforeEnter" v-on:enter="enter">
                        <el-col :span="6" v-for="item in classes" :key="item.id" v-bind:data-index="item">
                            <div class="class" @click="toClass(item.id,item.name)" v-add>
                                <div class="cover-box">
                                    <img :src="item.cover" alt="作品封面" width="100%">
                                    <p class="class-title">{{item.name}}</p>
                                </div>
                                <div class="info-box">
                                    <p><span>授课老师:</span> &nbsp;{{item.teachers[0].nickname}}</p>
                                    <p><span>上课进度:</span> &nbsp;{{item.finish_lesson_count}}/{{item.lesson_count}}</p>
                                    <el-progress
                                        :text-inside="true"
                                        :stroke-width="5"
                                        :percentage="item.finish_lesson_count / item.lesson_count * 100"
                                        :show-text='false'></el-progress>
                                </div>
                            </div>
                        </el-col>
                    </transition-group>
                </el-row>
            </div>
    
        </div>
    </template>
    
    <script>
        let ind = 0
        import axios from "axios";
        export default {
            data() {
                return {
                    ...
                }
            },
            created(){
                ind = 0
            },
            methods: {
                beforeEnter (el) {
                    console.log('beforeEnter => ')
                    //el.style.opacity = 0
                    el.style.paddingTop = '100px'
                },
                // 知乎Vue列表动画 https://zhuanlan.zhihu.com/p/219783692
                enter (el, done) {
                    console.log('enter => ',el.dataset.index)
                    let delay = ind * 100
                    ind +=1
                    setTimeout(()=>{
                        //el.style.opacity = 1
                       // el.style.transition = 'opacity 1s '
                        el.style.animation = 'one-in 0.5s'
                        // el.style.animation = 'one-in 4s infinite'
                        //el.style['animation-iteration-count'] = 1
                        el.style.paddingTop = '0px'
                        done()
                    }, delay)
                }
            },
        }
    </script>
    
    <!-- Add "scoped" attribute to limit CSS to this component only -->
    <style>
        @keyframes one-in{
            from {
                padding-top: 100px;
            }
            to {
                padding-top: 0%;
            }
        }
    </style>
    <style scoped>
    </style>
  • 相关阅读:
    DIV+CSS—菜鸟分享学习心得!入门篇
    有关 JavaScript 的 10 件让人费解的事情
    [论离职]走的人不少,来的人更多
    面朝电脑,春暖花开
    职场小说:《米亚快跑》PDF版下载
    flex和html的对比
    10个可以简化开发过程的MySQL工具
    转:大型网站架构不得不考虑的10个问题
    怎样善用色彩层次?40个精彩站点给你灵感
    50个令人耳目一新的网页纹理设计
  • 原文地址:https://www.cnblogs.com/Oldz/p/14299068.html
Copyright © 2011-2022 走看看