2.2.1 • Published 5 months ago

animation-list v2.2.1

Weekly downloads
-
License
ISC
Repository
github
Last release
5 months ago

animation-list

简介

https://img-blog.csdnimg.cn/e7208f78e2a8455090da6bfebd23e41a.gif#pic_center

  • animation-list 基于vue列表动画插件,支持vue3.0
  • 支持每个元素的动画监听(start,update,end)

引用

  • 安装
npm i animation-list
  • 例子
<template>
  <AnimationList ref="animationListRef">
    <div class="item" v-for="item in 8" :key="item">{{ item }}</div>
  </AnimationList>
</template>

<script lang="ts" setup>
import { onMounted, ref } from 'vue'
import AnimationList from 'animation-list/AnimationList.vue'
const animationListRef = ref<InstanceType<typeof AnimationList>>()
onMounted(() => {
  animationListRef.value?.initHooks({
    end: () => {
        console.log('动画结束')
        animationListRef.value?.animationCall() // 重新触发动画
    }
  })
})
</script>

<style  scoped>
.animation-list {
  overflow: hidden;
}
</style>

参数

属性

参数默认值备注
firstShowtrue默认是否渲染动画
deepfalse是否深层查找
animationTypeANIMATION_TYPE.RIGHT_LEFT默认从右到左动画

ANIMATION_TYPE默认动画

key动画效果备注
BOTTOM_TOPbottom-top从下向上
TOP_BOTTOMtop-bottom从上向下
RIGHT_LEFTright-left从右到左默认
LEFT_RIGHTleft-right从左到右
SAMLL_BIGsmall-big从小到大
BIG_SMALLbig-small从大到小
CUSTOMcustom自定义动画根据例子自定义动画

异步渲染流程

// 1.设置属性取消默认渲染动画 firstShow
// 2.获取数据后重新触发
import { onMounted, ref,nextTick } from 'vue'
setTimeout(() => {
    // 获取数据
    nextTick(() => {
        animationListRef.value?.animationCall()
    })
}, 1500)

自定义动画

<template>
<AnimationList ref="animationListRef" :animationType="ANIMATION_TYPE.CUSTOM">
    <div class="item" v-for="item in 8" :key="item">{{ item }}</div>
    </AnimationList>
</template>
<script lang="ts" setup>
    import AnimationList from 'animation-list/AnimationList.vue'
    import { ANIMATION_TYPE } from "animation-list/uitls";

</script>

<style  scoped>
    .animation-list {
        overflow: hidden;
    }
    /** 自定义动画部分(必须) **/
    .ls-custom {
        display: block;
        opacity: 1 !important;
        animation: ls-custom ease 0.26s !important;
    }
    @keyframes ls-custom {
        0% {
            opacity: 0;
            transform: scale(1.6);
        }
        100% {
            opacity: 1;
            transform: scale(1);
        }
    }

</style>
  • 在 style 样式加入
    • ls-custom 初始化
    • ls-custom 动画开始
    • keyframes 动画

hooks生命周期

animationListRef.value?.initHooks({
    start:()=>{},
    update:(params: { index: number; el: HTMLElement | Element }) => {},
    end:()=>{}
})

  • 1.x.x - vue2 相关文档,请以该版本的 README 为准

  • 2.x.x - vue3

2.2.1

5 months ago

2.2.0

5 months ago

2.1.6

10 months ago

2.1.7

10 months ago

2.1.2

1 year ago

2.1.4

1 year ago

2.1.3

1 year ago

2.1.5

1 year ago

2.1.0

1 year ago

2.0.4

1 year ago

2.0.3

1 year ago

2.0.2

1 year ago

2.0.1

1 year ago

2.0.0

1 year ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago