src
Sets or gets the source of the Lottie animation.
Description
Setting the src
property changes the displayed Lottie element to
the Lottie animation found at the specified src
value.
Getting the src
property returns the source of the
current Lottie animation.
The src
property can either be an external Lottie animation URL, for example, 'https://assets6.lottiefiles.com/private_files/lf30_vuxs5lpt.json'
, or a valid Lottie JSON.
A valid Lottie JSON file should follow this schema animation.json file. While your Lottie JSON file doesn't need all the key-value properties listed in this file, it must include the following properties and types for your Lottie JSON file to be valid.
Properties | Type |
---|---|
"w", "h", "ip", "op" | Number |
"assets", "layers" | Array of objects |
Tip: To set the src
property to a valid Lottie JSON, you can put it in a public file and import it in your page code.
Type:
Was this helpful?
1let lottieSource = $w('#myLottie').src;2// 'https://assets10.lottiefiles.com/private_files/lf30_0ffmp6vx.json'
1let lottieSource = $w('#myLottie').src;23/*4 {5 "v": "5.7.6",6 "fr": 60,7 "ip": 08 "op": 1219 "w": 225010 "h": 317711 "nm": "gatito final2 1"12 "ddd": 013 "assets": [...]14 "layers": [...]15 "markers": [...]16 }17*/
1$w('#myLottie').src = 'https://assets10.lottiefiles.com/private_files/lf30_0ffmp6vx.json';
This example demonstrates how to import a valid JSON file to your page code.
1/*************************************2 * Public code - myLottieJsonFile.js *3 ************************************/45export const myLottieJson =6{7 "v":"5.7.6",8 "fr":60,9 "ip":0,10 "op":121,11 "w":2250,12 "h":3177,13 "nm":"gatito final2 1",14 "ddd":0,"assets":[],15 "layers":16 [17 { "ddd":0,18 "ind":1,19 "ty":4,20 "nm":"path2009"21 },22 { "ddd":1,23 "ind":2,24 "ty":6,25 "nm":"path2010"26 }27 ]28};29303132/*************33 * Page code *34 ************/3536import { myLottieJson } from 'public/myLottieJsonFile.js';3738$w.onReady(function () {39 $w('#myLottie').src = myLottieJson;40});