Gathering detailed insights and metrics for @reslear/vue3-lottie
Gathering detailed insights and metrics for @reslear/vue3-lottie
Gathering detailed insights and metrics for @reslear/vue3-lottie
Gathering detailed insights and metrics for @reslear/vue3-lottie
A simple Vue 3 component for using Lottie animations in Vue 3
npm install @reslear/vue3-lottie
Typescript
Module System
Min. Node Version
Node Version
NPM Version
Vue (86.55%)
TypeScript (11.85%)
HTML (1.6%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
650 Commits
4 Branches
1 Contributors
Updated on Oct 19, 2022
Latest Version
1.0.0
Package Id
@reslear/vue3-lottie@1.0.0
Unpacked Size
22.75 kB
Size
7.34 kB
File Count
10
NPM Version
10.8.1
Node Version
22.3.0
Published on
Oct 24, 2024
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
1
fork of vue3-lottie
Changes:
.lottie
supportvue3-lottie
and install @reslear/vue3-lottie
1- import 'vue3-lottie/dist/style.css'
Rename events names, also need remove on
prefix:
2.x | 3.x |
---|---|
@onComplete | @complete |
@onLoopComplete | @loop-complete |
@onEnterFrame | @enter-frame |
@onSegmentStart | @segment-start |
@onAnimationLoaded | @animation-loaded |
1- <Vue3Lottie :animationData="AstronautJSON" @onComplete="onComplete" /> 2+ <Vue3Lottie :animationData="AstronautJSON" @complete="onComplete" />
You can use one of the strategies:
Bundle as assets your animation data with your application and import it into your component.
You app will be bigger (any json files bundled in to you script files and so we get a larger size because of internal optimizations for support in different browsers)
Recommended this strategy if you need to quickly load and render animation, for example in places where you want to see it first - dashboards, welcome screen, the first slide, etc.
1<template> 2 <Vue3Lottie :animationData="AstronautJSON" :height="200" :width="200" /> 3</template> 4 5<script script="setup" lang="ts"> 6import { Vue3Lottie } from '@reslear/vue3-lottie' 7import AstronautJSON from '../assets/astronaut.json' 8</script>
Load animation data from URL, but you will have problems with CORS and slow loading animation data, recommend host animation data on your public
folder and set animationLink
to relative path.
1<template> 2 <Vue3Lottie 3 animationLink="https://assets10.lottiefiles.com/packages/lf20_soCRuE.json" 4 :height="200" 5 :width="200" 6 /> 7 8 <Vue3Lottie animationLink="/animation-data.json" :height="200" :width="200" /> 9</template>
Same as above, but with support for dotLottie .lottie
file format, preferred way to load animation data from URL. Fetching a small compressed format animation in the browser is unpacked and render on the fly.
We use own tiny powerful engine dotlottie-player-core to prepare data.
For converting .json
to .lottie
use dotlottie-web-converter.
Recommended in all other cases where you do not need a strategy with assets import.
1<template> 2 <Vue3Lottie 3 animationLink="https://assets10.lottiefiles.com/packages/lf20_soCRuE.lottie" 4 :height="200" 5 :width="200" 6 /> 7</template>
Strategy | Fast painting | Fast bundling | Not bundled | Compressed | No CORS problems |
---|---|---|---|---|---|
Assets | ✅ | ❌ | ❌ | ❌ | ✅ |
fetch .json | ⚠️ | ✅ | ✅ | ❌ | ✅ |
fetch external .json | ⚠️ | ✅ | ✅ | ❌ | ⚠️ |
fetch .lottie | ⚠️ | ✅ | ✅ | ✅ | ✅ |
fetch external .json | ⚠️ | ✅ | ✅ | ✅ | ⚠️ |
Prop | Type | Default Value | Description |
---|---|---|---|
animationData | Object/String | "" | The lottie animation data provided as a JSON or String JSON |
animationLink | String | "" | A URL link to the Lottie animation data (eg: Lottie Animation URL on lottiefiles.com also support dotLottie .lottie ) file format. |
width | Number/String | 100% | Width of the lottie animation container (Numbers correspond to pixel values) |
height | Number/String | 100% | Height of the lottie animation container (Numbers correspond to pixel values) |
speed | Number | 1 | Speed of the lottie animation |
direction | String | "forward" | Animation play direction |
loop | Number or Boolean | true | The number of instances that the lottie animation should run (true is infinite) |
autoPlay | Boolean | true | Start animation on component load |
delay | Number | 0 | Delay the animation play state by some milliseconds |
pauseAnimation | Boolean | false | Prop to pass reactive variables so that you can control animation pause and play |
pauseOnHover | Boolean | false | Whether to pause the animation on hover |
playOnHover | Boolean | false | Whether to play the animation when you hover |
backgroundColor | String | transparent | Background color of the container |
renderer | String | "svg" | Set the renderer |
rendererSettings | Object | {} | Options for if you want to use an existing canvas to draw (can be ignored on most cases) |
We can use LottieProps
to define options interface.
1import type { LottieProps } from '@reslear/vue3-lottie'
A few events are emitted from the component. Look at the Demos for examples.
@complete
@loop-complete
@enter-frame
@segment-start
@animation-loaded
Example:
1<Vue3Lottie animationLink="anim.json" @loop-complete="log('loop complete 1')" />
You can control the animation with the following methods. These methods can be called by assigning a ref
value to the @reslear/vue3-lottie
component. Look at the Demos for examples.
No vulnerabilities found.
No security vulnerabilities found.