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

@lottiefiles/lottie-player

Package Overview
Dependencies
Maintainers
3
Versions
62
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@lottiefiles/lottie-player - npm Package Compare versions

Comparing version 0.5.1 to 1.0.0

dist/lottie-player.d.ts

32

package.json
{
"name": "@lottiefiles/lottie-player",
"version": "0.5.1",
"version": "1.0.0",
"description": "Lottie animation and Telegram Sticker player web components.",
"main": "dist/lottie-player.js",
"module": "dist/lottie-player.js",
"module": "dist/lottie-player.esm.js",
"types": "dist/lottie-player.d.ts",

@@ -14,6 +14,9 @@ "homepage": "https://lottiefiles.com/web-player",

"scripts": {
"build": "yarn build-lottie && yarn build-tgs",
"build-lottie": "parcel build src/lottie-player.ts --detailed-report 50 --out-file lottie-player.js",
"build-tgs": "parcel build src/tgs-player.ts --detailed-report 50 --out-file tgs-player.js",
"start": "parcel src/index.html"
"start": "npm run cleanup && rollup -c --watch",
"build": "npm run cleanup && npm run build-lottie && npm run build-tgs",
"build-lottie": "rollup -c ",
"build-tgs": "rollup -c rollup-tgs.config.js",
"watch-lottie": "npm run cleanup && rollup -c --watch",
"watch-tgs": "npm run cleanup && rollup -c rollup-tgs.config.js --watch",
"cleanup": "rm -rf dist && mkdir dist"
},

@@ -29,3 +32,18 @@ "dependencies": {

"parcel-bundler": "^1.12.4",
"typescript": "^3.4.5"
"typescript": "^3.4.5",
"@babel/core": "^7.11.0",
"@babel/plugin-proposal-class-properties": "^7.10.4",
"@babel/plugin-proposal-decorators": "^7.10.5",
"@babel/preset-env": "^7.11.0",
"@babel/preset-typescript": "^7.10.4",
"@rollup/plugin-babel": "^5.1.0",
"@rollup/plugin-commonjs": "^14.0.0",
"@rollup/plugin-node-resolve": "^8.4.0",
"rollup": "^2.23.0",
"rollup-plugin-copy": "^3.3.0",
"rollup-plugin-filesize": "^9.0.2",
"rollup-plugin-serve": "^1.0.3",
"rollup-plugin-terser": "^6.1.0",
"rollup-plugin-typescript2": "^0.27.1",
"rollup-plugin-visualizer": "^4.0.4"
},

@@ -32,0 +50,0 @@ "files": [

@@ -109,6 +109,141 @@ ## lottie-player Web Component

### ReactJS & VueJS
Import the player either as
```js
import * as LottiePlayer from "@lottiefiles/lottie-player";
```
or
```js
require("@lottiefiles/lottie-player");
```
Use as follows
```html
<lottie-player
autoplay
controls
loop
mode="normal"
src="https://assets3.lottiefiles.com/packages/lf20_UJNc2t.json"
style="width: 320px"
></lottie-player>
```
### Typescript ReactJS
Import the player either as
```js
import * as LottiePlayer from "@lottiefiles/lottie-player";
```
or
```js
require("@lottiefiles/lottie-player");
```
Use as follows
```html
<lottie-player
autoplay
controls
loop
mode="normal"
src="https://assets3.lottiefiles.com/packages/lf20_UJNc2t.json"
style="width: 320px"
></lottie-player>
```
For typescript projects an added step is required. The component must be declared as a JSX intrinsic element. Create a file 'declarations.d.ts' in the root of your project and add the code below to the file.
```js
declare namespace JSX {
interface IntrinsicElements {
"lottie-player": any;
}
}
```
### NuxtJS
The process for NuxtJS is slightly different. Create a lottie-player.js file in project root inside a folder named 'plugins'. Add the code below to the file
```js
import * as LottiePlayer from "@lottiefiles/lottie-player";
```
Open nuxt.config.js file and adjust the plugins array as shown below
```js
plugins: [{ src: "~/plugins/lottie-player.js", mode: "client" }],
```
You would then be able to use the player as follows inside any component
```html
<lottie-player
autoplay
controls
loop
style="width:400px"
src="https://assets3.lottiefiles.com/packages/lf20_RItkEz.json"
speed="1"
debug
></lottie-player>
```
This is because the player script needs to be rendered on the browser/client side and we must configure nuxtjs to load the script on the client side only.
### NextJS
The process to import in NextJS is similar to NuxtJS in the sense that on SSR mode, the library must be declared as a client side module. To do this, import the library within a react useEffect hook.
```javascript
import React, { useRef } from "react";
export default function Home() {
const ref = useRef(null);
React.useEffect(() => {
import("@lottiefiles/lottie-player");
});
return (
<div className={styles.container}>
<main className={styles.main}>
<lottie-player
id="firstLottie"
ref={ref}
autoplay
controls
loop
mode="normal"
src="https://assets4.lottiefiles.com/packages/lf20_gb5bmwlm.json"
style={{ width: "300px", height: "300px" }}
></lottie-player>
</main>
</div>
);
}
```
Do add a declaration file named declaration.d.ts to the root of the project as well
```javascript
declare namespace JSX {
interface IntrinsicElements {
"lottie-player": any;
}
}
```
## Properties
| Property | Attribute | Description | Type | Default |
| --------------------- | --------------------- | ----------------------------------- | ------------------------------------ | ----------------- |
| --------------------- | --------------------- | ----------------------------------- | ------------------------------------ | ----------------- | ------- |
| `autoplay` | `autoplay` | Autoplay animation on load. | `boolean` | `false` |

@@ -123,3 +258,3 @@ | `background` | `background` | Background color. | `string` | `undefined` |

| `preserveAspectRatio` | `preserveAspectRatio` | Valid preserve aspect ratio value. | `string` | `'xMidYMid meet'` |
| `renderer` | `renderer` | Renderer to use. | `"svg" | "canvas"` | `'svg'` |
| `renderer` | `renderer` | Renderer to use. | `"svg" | "canvas"` | `'svg'` |
| `speed` | `speed` | Animation speed. | `number` | `1` |

@@ -126,0 +261,0 @@ | `src` _(required)_ | `src` | Bodymovin JSON data or URL to JSON. | `string` | `undefined` |

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

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