0.2.5 • Published 4 days ago

@lottiefiles/dotlottie-vue v0.2.5

Weekly downloads
-
License
MIT
Repository
github
Last release
4 days ago

@lottiefiles/dotlottie-vue

npm npm bundle size npm NPM

Contents

Introduction

A Vue library for rendering lottie and dotLottie animations in the browser.

What is dotLottie?

dotLottie is an open-source file format that aggregates one or more Lottie files and their associated resources into a single file. They are ZIP archives compressed with the Deflate compression method and carry the file extension of ".lottie".

Learn more about dotLottie.

Installation

npm install @lottiefiles/dotlottie-vue

Usage

<script setup>
import { DotLottieVue } from '@lottiefiles/dotlottie-vue'
</script>

<template>
  <DotLottieVue style="height: 500px; width: 500px" autoplay loop src="https://path-to-lottie.lottie" />
</template>

Live Examples

  • Basic Example

APIs

DotLottieVue Props

Property nameTypeRequiredDefaultDescription
autoplaybooleanfalseAuto-starts the animation on load.
loopbooleanfalseDetermines if the animation should loop.
srcstringundefinedURL to the animation data (.json or .lottie).
speednumber1Animation playback speed. 1 is regular speed.
datastring | ArrayBufferundefinedAnimation data provided either as a Lottie JSON string or as an ArrayBuffer for .lottie animations.
modestring"forward"Animation play mode. Accepts "forward", "reverse", "bounce", "reverse-bounce".
backgroundColorstringundefinedBackground color of the canvas. Accepts 6-digit or 8-digit hex color string (e.g., "#000000", "#000000FF"),
segment[number, number][0, totalFrames - 1]Animation segment. Accepts an array of two numbers, where the first number is the start frame and the second number is the end frame.
renderConfigRenderConfig{}Configuration for rendering the animation.
useFrameInterpolationbooleanfalseDetermines if the animation should update on subframes. If set to false, the original AE frame rate will be maintained. If set to true, it will refresh at each requestAnimationFrame, including intermediate values. The default setting is true.

RenderConfig

The renderConfig object accepts the following properties:

Property nameTypeRequiredDefaultDescription
devicePixelRationumberwindow.devicePixelRatio | 1The device pixel ratio.

Listening to Events

<script setup>
import { onMounted, ref, watch } from 'vue';
import { DotLottieVue } from '@lottiefiles/dotlottie-vue'
const playerRef = ref(null);

onMounted(() => {
  if (playerRef.value) {
    const dotLottie = playerRef.value.getDotLottieInstance();
    dotLottie.addEventListener('pause', () => {
      console.log('paused')
    });
    dotlottie.addEventListener('frame', ({ currentFrame }) => {
      console.log('Frame:', currentFrame)
    });
  }
})
</script>

<template>
  <DotLottieVue autoplay loop ref="playerRef" src="path-to-lottie.lottie" />
</template>

Refer to dotlottie-web Events sections to know more about all available events.

Development

Setup

pnpm install

Dev

pnpm dev

Build

pnpm build
0.2.5

4 days ago

0.2.4

1 month ago

0.2.3

1 month ago

0.2.2

2 months ago

0.2.1

2 months ago

0.2.0

2 months ago

0.1.9

2 months ago

0.1.8

3 months ago

0.1.7

3 months ago

0.1.6

3 months ago

0.1.5-beta.1

3 months ago

0.1.5

3 months ago

0.1.5-beta.0

4 months ago

0.1.4

4 months ago

0.1.2

4 months ago

0.1.3

4 months ago

0.1.1

4 months ago

0.1.0

4 months ago