This LightningJS v2 project, based on the default template, implements a LottieViewer
component.
Animation is imported as JSON data:
import LottieViewer from './LottieViewer'
import lottieAnimData from './LottieAnim.json'
LottieViewer
can then be used in component templates:
LottieAnim: {
type: LottieViewer,
// start playback automatically (default true)
autoPlay: true,
// loop animation (default true)
loop: true,
// rendered size (default original animation size)
width: 200,
height: 200,
// Lottie JSON data (set last)
animationData: lottieAnimData,
},
With a reference to the component (e.g. this.tag('LottieAnim')
), the following API is provided (and could be easily extended):
anim.isLoaded
anim.isPaused
anim.play()
anim.pause()
In this demo project, Enter key should toggle the animation (pause/play).
Before you follow the steps below, make sure you have the Lightning-CLI installed globally only your system
npm install -g @lightningjs/cli
-
Install the NPM dependencies by running
npm install
-
Build the App using the Lightning-CLI by running
lng build
inside the root of your project -
Fire up a local webserver and open the App in a browser by running
lng serve
inside the root of your project
During development you can use the watcher functionality of the Lightning-CLI.
- use
lng watch
to automatically rebuild your App whenever you make a change in thesrc
orstatic
folder - use
lng dev
to start the watcher and run a local webserver / open the App in a browser at the same time
Use lng docs
to open up the Lightning-SDK documentation.
ISC License
Copyright 2023 Philippe Elsass
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.