@lottiefiles/lottie-player 1.5.7 → 1.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +38 -9
- package/dist/lottie-player.esm.js +1 -1
- package/dist/lottie-player.esm.js.map +1 -1
- package/dist/lottie-player.js +2 -2
- package/dist/lottie-player.js.map +1 -1
- package/dist/tgs-player.esm.js +9 -9
- package/dist/tgs-player.esm.js.map +1 -1
- package/dist/tgs-player.js +9 -9
- package/dist/tgs-player.js.map +1 -1
- package/package.json +2 -2
- package/CHANGELOG.md +0 -193
package/README.md
CHANGED
|
@@ -171,21 +171,52 @@ declare namespace JSX {
|
|
|
171
171
|
}
|
|
172
172
|
```
|
|
173
173
|
|
|
174
|
-
###
|
|
174
|
+
### Nuxt 2
|
|
175
175
|
|
|
176
|
-
|
|
176
|
+
Create a `lottie-player.js` file inside the `/plugins` folder and add the below code to the file:
|
|
177
177
|
|
|
178
178
|
```js
|
|
179
179
|
import * as LottiePlayer from "@lottiefiles/lottie-player";
|
|
180
|
+
```
|
|
181
|
+
\
|
|
182
|
+
Open `nuxt.config.js` file and add the following entry to register the newly created plugin:
|
|
183
|
+
|
|
184
|
+
```js
|
|
185
|
+
export default {
|
|
186
|
+
plugins: [{ src: "~/plugins/lottie-player.js", mode: "client" }]
|
|
187
|
+
}
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
This is because the player script needs to be rendered on the browser/client side and we must configure Nuxt to load the script on the client side only.
|
|
191
|
+
\
|
|
192
|
+
You would then be able to use the player as follows inside any component:
|
|
193
|
+
|
|
194
|
+
```html
|
|
195
|
+
<lottie-player
|
|
196
|
+
autoplay
|
|
197
|
+
controls
|
|
198
|
+
loop
|
|
199
|
+
style="width:400px"
|
|
200
|
+
src="https://assets3.lottiefiles.com/packages/lf20_RItkEz.json"
|
|
201
|
+
speed="1"
|
|
202
|
+
debug
|
|
203
|
+
/>
|
|
180
204
|
```
|
|
181
205
|
|
|
182
|
-
|
|
206
|
+
### Nuxt 3
|
|
207
|
+
|
|
208
|
+
The process for Nuxt 3 is slightly different.
|
|
209
|
+
Create a `lottie-player.client.ts` file inside the `/plugins` folder and add the below code to the file:
|
|
183
210
|
|
|
184
211
|
```js
|
|
185
|
-
|
|
212
|
+
import * as LottiePlayer from "@lottiefiles/lottie-player";
|
|
213
|
+
|
|
214
|
+
export default LottiePlayer;
|
|
186
215
|
```
|
|
216
|
+
\
|
|
217
|
+
Your plugin will be automatically available throughout your Nuxt application thanks to the [plugin auto-registration](https://v3.nuxtjs.org/guide/directory-structure/plugins). Note the `client` suffix in the name of the plugin - this tells Nuxt to load it only on the client side, as the Lottie Player script can only be rendered in the browser.
|
|
187
218
|
|
|
188
|
-
You would then be able to use the player as follows inside any component
|
|
219
|
+
You would then be able to use the player as follows inside any component:
|
|
189
220
|
|
|
190
221
|
```html
|
|
191
222
|
<lottie-player
|
|
@@ -196,14 +227,12 @@ You would then be able to use the player as follows inside any component
|
|
|
196
227
|
src="https://assets3.lottiefiles.com/packages/lf20_RItkEz.json"
|
|
197
228
|
speed="1"
|
|
198
229
|
debug
|
|
199
|
-
|
|
230
|
+
/>
|
|
200
231
|
```
|
|
201
232
|
|
|
202
|
-
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.
|
|
203
|
-
|
|
204
233
|
### NextJS
|
|
205
234
|
|
|
206
|
-
The process to import in NextJS is similar to
|
|
235
|
+
The process to import in NextJS is similar to Nuxt 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.
|
|
207
236
|
|
|
208
237
|
```javascript
|
|
209
238
|
import React, { useRef } from "react";
|