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

vue3-lottie

Package Overview
Dependencies
Maintainers
1
Versions
62
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vue3-lottie - npm Package Compare versions

Comparing version 2.3.1 to 2.3.2

5

package.json
{
"name": "vue3-lottie",
"version": "2.3.1",
"version": "2.3.2",
"license": "MIT",

@@ -63,3 +63,4 @@ "author": "Sanjay Soundarajan <info@sanjaysoundarajan.dev> (https://sanjaysoundarajan.dev)",

"prettier": "npx prettier --write ."
}
},
"readme": "# Vue 3 Lottie\r\n\r\n[![npm](https://img.shields.io/npm/v/vue3-lottie)](https://www.npmjs.com/package/vue3-lottie) [![Downloads](https://img.shields.io/npm/dt/vue3-lottie)](https://www.npmjs.com/package/vue3-lottie) [![Stars](https://img.shields.io/github/stars/megasanjay/vue3-lottie.svg?style=flat-square)](https://github.com/megasanjay/vue3-lottie/stargazers) [![License](https://img.shields.io/npm/l/vue3-lottie)](https://github.com/megasanjay/vue3-lottie/blob/main/LICENSE) [![GitHub issues](https://img.shields.io/github/issues/megasanjay/vue3-lottie)](https://github.com/megasanjay/vue3-lottie/issues)\r\n\r\n`vue3-lottie` was created to help developers add Lottie animations to their Vue 3 applications. In my search for a simple way to add Lottie animations to my Vue application I found a suprising lack of maintained solutions. `vue3-lottie` is a vue wrapper around the `lottie-web` library with a few additional features.\r\n\r\n# Demos\r\n\r\nView the live demos here: [https://vue3-lottie.vercel.app](https://vue3-lottie.vercel.app)\r\n\r\n# Upgrade to v2.x\r\n\r\nIf you are using version 1.x of `vue3-lottie` you should upgrade to version 2.x. You can do this by running the [Installation and Usage](#installation-and-usage) command below. This adds TS support for the component. There are some new imports so take a look at the [new documentation](https://vue3-lottie.vercel.app/guide.html#usage).\r\n\r\n# Installation and Usage\r\n\r\n## Vue 3\r\n\r\n- You can install `vue3-lottie` over `yarn` or `npm`. `lottie-web` is a dependency of `vue3-lottie` and should be automatically installed when you install `vue3-lottie`.\r\n\r\nIf you are using npm:\r\n\r\n```shell\r\nnpm install vue3-lottie@latest --save\r\n```\r\n\r\nIf you are using yarn:\r\n\r\n```shell\r\nyarn add vue3-lottie@latest\r\n```\r\n\r\n- Register the component in your Vue 3 application.\r\n\r\nThe most common use case is to register the component globally.\r\n\r\n```js\r\n// main.js\r\nimport { createApp } from 'vue'\r\nimport Vue3Lottie from 'vue3-lottie'\r\nimport 'vue3-lottie/dist/style.css'\r\n\r\ncreateApp(App).use(Vue3Lottie).mount('#app')\r\n```\r\n\r\nTo define global components for [Volar type-checking](https://github.com/johnsoncodehk/volar/tree/master/extensions/vscode-vue-language-features#usage) you will need to add:\r\n\r\n```ts\r\n// components.d.ts\r\ndeclare module '@vue/runtime-core' {\r\n export interface GlobalComponents {\r\n LottieAnimation: typeof import('vue3-lottie')['Vue3Lottie']\r\n }\r\n}\r\nexport {}\r\n```\r\n\r\nIf needed rename component to use:\r\n\r\n```ts\r\napp.use(Vue3Lottie, { name: 'LottieAnimation' }) // use in template <LottieAnimation />\r\n```\r\n\r\n- `name` string (default: 'Vue3Lottie') - set custom component name\r\n\r\nAlternatively you can also import the component locally.\r\n\r\n```js\r\nimport { Vue3Lottie } from 'vue3-lottie'\r\nimport 'vue3-lottie/dist/style.css'\r\n\r\nexport default {\r\n components: {\r\n Vue3Lottie,\r\n },\r\n}\r\n```\r\n\r\nYou can then use the component in your template\r\n\r\n```vue\r\n<template>\r\n <Vue3Lottie :animationData=\"AstronautJSON\" :height=\"200\" :width=\"200\" />\r\n</template>\r\n\r\n<script>\r\nimport { Vue3Lottie } from 'vue3-lottie'\r\nimport 'vue3-lottie/dist/style.css'\r\n\r\nimport AstronautJSON from './astronaut.json'\r\n\r\nexport default {\r\n components: {\r\n Vue3Lottie,\r\n },\r\n data() {\r\n return {\r\n AstronautJSON,\r\n }\r\n },\r\n}\r\n</script>\r\n```\r\n\r\n## Nuxt 3\r\n\r\nThis is still experimental. Will be updated soon.\r\n\r\n- You can install `vue3-lottie` over `yarn` or `npm`. `lottie-web` is a dependency of `vue3-lottie` and should be automatically installed when you install `vue3-lottie`.\r\n\r\nIf you are using npm:\r\n\r\n```shell\r\nnpm install vue3-lottie@latest --save\r\n```\r\n\r\nIf you are using yarn:\r\n\r\n```shell\r\nyarn add vue3-lottie@latest\r\n```\r\n\r\n- Create a folder called **`plugins`** at the root of your project.\r\n- Create a file named **`Vue3Lottie.client.ts`** inside the _plugins_ directory.\r\n- Add the following code to the **`Vue3Lottie.client.ts`** file.\r\n\r\n```ts\r\nimport Vue3Lottie from 'vue3-lottie'\r\n\r\nexport default defineNuxtPlugin((nuxtApp) => {\r\n nuxtApp.vueApp.use(Vue3Lottie)\r\n})\r\n```\r\n\r\nThis should register as a global component that you can call anywhere in your app under the <Vue3Lottie> tag.\r\n\r\nI would recommend using a `<client-only>` parent tag to ensure that the animation only loads in on the client side.\r\n\r\n```vue\r\n<client-only>\r\n <Vue3Lottie\r\n animationLink=\"https://assets10.lottiefiles.com/packages/lf20_soCRuE.json\"\r\n :height=\"200\"\r\n :width=\"200\"\r\n />\r\n</client-only>\r\n```\r\n\r\n- Import the css file required by the component into your **`app.vue`** file.\r\n\r\n```js\r\nimport 'vue3-lottie/dist/style.css'\r\n```\r\n\r\n# Props and options\r\n\r\nMore detailed explanations are provided in the [documentation](https://vue3-lottie.vercel.app/guide.html).\r\n\r\n| Prop | Type | Default Value | Description |\r\n| ---------------- | ----------------- | ------------- | ---------------------------------------------------------------------------------------- |\r\n| animationData | Object | {} | The lottie animation data provided as a JSON object |\r\n| animationLink | String | '' | A URL link to the Lottie animation data (eg: `Lottie Animation URL` on lottiefiles.com) |\r\n| width | Number or String | \"100%\" | Width of the lottie animation container (Numbers correspond to pixel values) |\r\n| height | Number or String | \"100%\" | Height of the lottie animation container (Numbers correspond to pixel values) |\r\n| speed | Number | \"1\" | Speed of the lottie animation |\r\n| direction | String | \"forward\" | Animation play direction |\r\n| loop | Number or Boolean | true | The number of instances that the lottie animation should run (true is infinite) |\r\n| autoPlay | Boolean | true | Start animation on component load |\r\n| delay | Number | 0 | Delay the animation play state by some milliseconds |\r\n| pauseAnimation | Boolean | false | Prop to pass reactive variables so that you can control animation pause and play |\r\n| pauseOnHover | Boolean | false | Whether to pause the animation on hover |\r\n| playOnHover | Boolean | false | Whether to play the animation when you hover |\r\n| backgroundColor | String | transparent | Background color of the container |\r\n| rendererSettings | Object | {} | Options for if you want to use an existing canvas to draw (can be ignored on most cases) |\r\n\r\n# Events\r\n\r\nA few events are emitted from the component. Look at the [Demos](#Demos) for examples.\r\n\r\n- onComplete\r\n - If your animation has a finite amount of loops you can use this event to know when the animation has completed.\r\n- onLoopComplete\r\n - If your animation has a finite amount of loops you can use this event to know when the animation has completed a loop.\r\n- onEnterFrame\r\n - This event is fired every frame of the animation. There will be 60 events fired per second if your lottie animation runs at 60fps.\r\n- onSegmentStart\r\n - This event is fired when the animation enters a segment.\r\n- onAnimationLoaded\r\n - This event is fired when the animation has loaded. This should let you know when you can start referencing the methods for the component.\r\n\r\n# Methods\r\n\r\nYou can control the animation with the following methods. These methods can be called by assigning a `ref` value to the `vue3-lottie` component. Look at the [Demos](#Demos) for examples.\r\n\r\n- play\r\n - Plays the animation\r\n- pause\r\n - Pauses the animation\r\n- stop\r\n - Stops the animation. This will also reset the animation to the first frame. Look at the demo for some examples.\r\n- destroy\r\n - You can call this method to destroy the animation. It will remove the animation from the DOM.\r\n- setSpeed(speed)\r\n - You can call this method to change the speed of your animation.\r\n- setDirection(direction)\r\n - You can call this method to change the direction of your animation.\r\n- getDuration(inFrames)\r\n - You can call this method to get the duration of your animation.\r\n- goToAndStop(frameNumber, isFrames)\r\n - You can call this method to go to a specific frame of your animation. The animation will be stopped at the end of this call.\r\n- goToAndPlay(frameNumber, isFrames)\r\n - You can call this method to go to a specific frame of your animation. The animation will be played from this frame.\r\n- playSegments(segments, forceFlag)\r\n - You can call this method to play a specific segment of your animation.\r\n- setSubFrame(subFrame)\r\n - You can call this method to set the subframe value.\r\n- updateDocumentData(documentData, index)\r\n - This method updates text on text layers. Refer to the [official docs](https://github.com/airbnb/lottie-web/wiki/TextLayer.updateDocumentData) for how to use this method.\r\n\r\n# Credits\r\n\r\nA big thank you goes to [@reslear](https://github.com/reslear) for adding Typescript support to this library. Go check out his profile and give him a follow!\r\n\r\n- [@DamianGlowala](https://github.com/DamianGlowala) - PR [#29](https://github.com/megasanjay/vue3-lottie/pull/29) - Fix `watch` function\r\n\r\n![forthebadge](https://forthebadge.com/images/badges/made-with-vue.svg) ![forthebadge](https://forthebadge.com/images/badges/built-with-love.svg)\r\n"
}
dist/vue3-lottie.es.js

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

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

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