Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@lottiefiles/lottie-player

Package Overview
Dependencies
Maintainers
2
Versions
62
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@lottiefiles/lottie-player

Lottie animation player web component.

  • 0.0.5
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
111K
increased by13.37%
Maintainers
2
Weekly downloads
 
Created
Source

lottie-player Web Component

This is a Web Component for easily embedding and playing Lottie animations in websites.

npm webcomponents.org

Demo

screencast

View editable examples on CodeSandBox

Installation

In HTML, import from CDN or from the local Installation:
  • Import from CDN.
<script src="https://unpkg.com/@lottiefiles/lottie-player@0.0.5/dist/lottie-player.js"></script>
  • Import from local node_modules directory.
<script src="/node_modules/@lottiefiles/lottie-player/dist/lottie-player.js"></script>
In Javascript or TypeScript:
  1. Install package using npm or yarn.
npm install --save @lottiefiles/lottie-player
  1. Import package in your code.
import '@lottiefiles/lottie-player';

Usage

Add the element lottie-player and set the src property to a URL pointing to a valid Bodymovin JSON.

<lottie-player
    autoplay
    controls
    loop
    mode="normal"
    src="https://assets3.lottiefiles.com/packages/lf20_UJNc2t.json"
    style="width: 320px"
>
</lottie-player>

Properties

PropertyAttributeDescriptionTypeDefault
autoplayautoplayAutoplay animation on load.booleanfalse
backgroundbackgroundBackground color.stringundefined
controlscontrolsShow controls.booleanfalse
countcountNumber of times to loop animation.numberundefined
directiondirectionDirection of animation.number1
hoverhoverWhether to play on mouse hover.booleanfalse
looploopWhether to loop animation.booleanfalse
modemodePlay mode.PlayMode.Bounce | PlayMode.NormalPlayMode.Normal
rendererrendererRenderer to use."svg"'svg'
speedspeedAnimation speed.number1
src (required)srcBodymovin JSON data or URL to JSON.stringundefined

Methods

getLottie() => Promise<any>

Returns the instance of lottie player used in the component.

Returns

Type: Promise<any>

pause() => void

Pause animation play.

Returns

Type: void

play() => void

Start playing animation.

Returns

Type: void

setDirection(value: number) => void

Animation play direction.

Parameters
NameTypeDescription
valuenumberDirection values.
Returns

Type: void

setLooping(value: boolean) => void

Sets the looping of the animation.

Parameters
NameTypeDescription
valuebooleanWhether to enable looping. Boolean true enables looping.
Returns

Type: void

setSpeed(value?: number) => void

Sets animation play speed.

Parameters
NameTypeDescription
valuenumberPlayback speed.
Returns

Type: void

stop() => void

Stops animation play.

Returns

Type: void

seek(frame: number) => void

Seek to a given frame.

Returns

Type: void

snapshot(download?: boolean) => string

Snapshot the current frame as SVG. If 'download' argument is boolean true, then a download is triggered in browser.

Returns

Type: string

toggleLooping() => void

Toggles animation looping.

Returns

Type: void

togglePlay() => void

Toggle playing state.

Returns

Type: void

Styling

Custom propertyDescriptionDefault
--lottie-player-toolbar-heightToolbar height35px
--lottie-player-toolbar-background-colorToolbar background colortransparent
--lottie-player-toolbar-icon-colorToolbar icon color#999
--lottie-player-toolbar-icon-hover-colorToolbar icon hover color#222
--lottie-player-toolbar-icon-active-colorToolbar icon active color#555
--lottie-player-seeker-track-colorSeeker track color#CCC
--lottie-player-seeker-thumb-colorSeeker thumb colorrgba(0, 107, 120, 0.8)

License

MIT License © LottieFiles.com

Keywords

FAQs

Package last updated on 10 May 2019

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