New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@lottiefiles/dotlottie-web

Package Overview
Dependencies
Maintainers
4
Versions
92
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@lottiefiles/dotlottie-web

Lottie and DotLottie player for the web

  • 0.1.0
  • Source
  • npm
  • Socket score

Version published
Maintainers
4
Created
Source

@lottiefiles/dotlottie-web

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

🚧 Beta Alert: We're still refining! The APIs in this package may undergo changes.

Contents

Installation

npm install @lottiefiles/dotlottie-web

Usage

<!-- HTML -->
<canvas id="my-canvas"></canvas>
// JavaScript
import { DotLottie } from '@lottiefiles/dotlottie-web';

const dotLottie = new DotLottie({
    autoplay: true,
    loop: true,
    canvas: document.getElementById('my-canvas'),
    src: "https://example.com/path/to/animation.lottie", // or "https://example.com/path/to/animation.json"
});

Options

OptionTypeRequiredDefaultDescription
autoplaybooleanfalseAuto-starts the animation on load.
loopbooleanfalseDetermines if the animation should loop.
canvasHTMLCanvasElement✔️nullCanvas element for animation rendering.
srcstringnullURL to the animation data (.json or .lottie).
speednumber1Animation playback speed. 1 is regular speed.

Properties

PropertyTypeDescription
currentFramenumberRepresents the animation's currently displayed frame number.
durationnumberSpecifies the animation's total playback time in milliseconds.
totalFramesnumberDenotes the total count of individual frames within the animation.
loopbooleanIndicates if the animation is set to play in a continuous loop.
speednumberRepresents the playback speed factor; e.g., 2 would mean double speed.
loopCountnumberTracks how many times the animation has completed its loop.
playingbooleanReflects whether the animation is in active playback or not

Methods

MethodDescription
play()Begins playback from the current animation position.
pause()Pauses the animation without resetting its position.
stop()Halts playback and returns the animation to its initial frame.
setSpeed(speed: number)Sets the playback speed with the given multiplier.
setLoop(loop: boolean)Configures whether the animation should loop continuously.
setFrame(frame: number)Directly navigates the animation to a specified frame.
addEventListener(event: string, listener: Function)Registers a function to respond to a specific animation event.
removeEventListener(event: string, listener?: Function)Removes a previously registered function from responding to a specific animation event.

Events

EventDescription
loadEmitted when the animation is loaded.
loadErrorEmitted when there's an error loading the animation.
playEmitted when the animation starts playing.
pauseEmitted when the animation is paused.
stopEmitted when the animation is stopped.
loopEmitted when the animation completes a loop.
completeEmitted when the animation completes.
frameEmitted when the animation reaches a new frame.

Development

Setup

pnpm install

Development

pnpm dev

Build

pnpm build

Build WASM (Optional)

Note: This step is necessary only if you wish to update the src/renderer.cpp file or the thorvg version being used. If not, you can skip this step.

Using Docker (Recommended):

pnpm build:wasm:docker

Using Emscripten SDK:

Ensure Emscripten SDK is installed.

pnpm build:wasm /path/to/emsdk/

Keywords

FAQs

Package last updated on 03 Nov 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc