Skip to content

Commit

Permalink
Merge pull request #3 from Applelo/dev
Browse files Browse the repository at this point in the history
Version 1.1.0
  • Loading branch information
Applelo authored Feb 20, 2023
2 parents 24cbde2 + f1ffb96 commit 627bc64
Show file tree
Hide file tree
Showing 6 changed files with 184 additions and 117 deletions.
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
auto-install-peers=true
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,30 @@ By default, Blottie will load the lighter version (`light`) of Lottie for the re
</template>
```

If needed, you can access the lottie player before the lottie `loadAnimation` method. You can use the `before-init` prop allowing you to pass an asynchrone callback with the player as an argument (check the example below).

This is necessary for allowing to use `setLocationHref` to [fix Safari issue](https://github.com/airbnb/lottie-web#issues).

<script setup lang="ts">
import type { LottiePlayer } from 'lottie-web'
import { Blottie } from './../..'

const beforeInit = async (player: LottiePlayer) => {
console.log(player)
}
</script>

<template>
<div>
<Blottie
class="animation"
path="vue-js.json"
:before-init="beforeInit"
:autoplay="true"
/>
</div>
</template>

An additional prop `container-tag` is available to change the default `div` tag container.

```vue
Expand Down
7 changes: 6 additions & 1 deletion demo/src/App.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script setup lang="ts">
import type { AnimationItem } from 'lottie-web'
import type { AnimationItem, LottiePlayer } from 'lottie-web'
import { ref } from 'vue'
import { Blottie, type BlottieExpose } from './../..'
import animVueJS from './assets/vue-js.json'
Expand All @@ -14,6 +14,10 @@ const onFrame = (anim?: AnimationItem) => {
const onReady = (anim?: AnimationItem | undefined) => {
anim?.play()
}
const beforeInit = async (player: LottiePlayer) => {
console.log(player)
}
</script>

<template>
Expand All @@ -24,6 +28,7 @@ const onReady = (anim?: AnimationItem | undefined) => {
class="animation"
path="vue-js.json"
@enter-frame="onFrame"
:before-init="beforeInit"
:autoplay="true"
:loop="true"
renderer="html"
Expand Down
21 changes: 12 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "blottie",
"type": "module",
"version": "1.0.1",
"version": "1.1.0",
"license": "GPL-3.0",
"description": "Lottie component for VueJS 3 / Nuxt 3 ",
"author": "Applelo",
Expand Down Expand Up @@ -49,15 +49,17 @@
"type"
],
"dependencies": {
"lottie-web": "^5.10.2",
"vue": "^3.2.47"
"lottie-web": "^5.10.2"
},
"peerDependencies": {
"vue": ">=3.0.0"
},
"devDependencies": {
"@types/node": "^18.13.0",
"@typescript-eslint/eslint-plugin": "^5.51.0",
"@typescript-eslint/parser": "^5.51.0",
"@types/node": "^18.14.0",
"@typescript-eslint/eslint-plugin": "^5.53.0",
"@typescript-eslint/parser": "^5.53.0",
"@vitejs/plugin-vue": "^4.0.0",
"cypress": "^12.5.1",
"cypress": "^12.6.0",
"eslint": "^8.34.0",
"eslint-config-prettier": "^8.6.0",
"eslint-define-config": "^1.15.0",
Expand All @@ -66,8 +68,9 @@
"lodash.get": "^4.4.2",
"prettier": "^2.8.4",
"typescript": "^4.9.5",
"vite": "^4.1.1",
"vue-tsc": "^1.0.24"
"vite": "^4.1.3",
"vue": "^3.2.47",
"vue-tsc": "^1.1.4"
},
"packageManager": "[email protected]",
"publishConfig": {
Expand Down
Loading

0 comments on commit 627bc64

Please sign in to comment.