
Security News
ESLint Adds Official Support for Linting HTML
ESLint now supports HTML linting with 48 new rules, expanding its language plugin system to cover more of the modern web development stack.
nativescript-lottie
Advanced tools
All notable changes to this project will be documented in the changelog.
The .gif does not do the fluid animations justice
To install execute:
NativeScript Version 7+:
ns plugin add nativescript-lottie
NativeScript Version prior to 7:
tns plugin add nativescript-lottie@4.0.1
<Page
xmlns="http://schemas.nativescript.org/tns.xsd"
xmlns:Lottie="nativescript-lottie" navigatingTo="navigatingTo" class="page">
<StackLayout>
<Lottie:LottieView src="PinJump.json" height="130" loop="true" autoPlay="true" loaded="yourLoadedEvent" />
</StackLayout>
</Page>
import { LottieView } from "nativescript-lottie";
public yourLoadedEvent(args) {
this._myLottie = args.object as LottieView; /// this is the instance of the LottieAnimationView
this._myLottie.loop = false; // to get the completionBlock to fire the animation can not be looping because then it will never "complete"
this._myLottie.completionBlock = (bool) => {
console.log('lottie animaton complete', bool);
}
}
<StackLayout>
<LottieView width="100" height="150" [src]="src" [loop]="loop" [autoPlay]="autoPlay" (loaded)="lottieViewLoaded($event)"></LottieView>
</StackLayout>
import { Component } from '@angular/core';
import { registerElement } from '@nativescript/angular';
import { LottieView } from 'nativescript-lottie';
registerElement('LottieView', () => LottieView);
@Component({
templateUrl: 'home.component.html',
moduleId: module.id
})
export class HomeComponent {
public loop: boolean = true;
public src: string;
public autoPlay: boolean = true;
public animations: Array<string>;
private _lottieView: LottieView;
constructor() {
this.animations = [
'Mobilo/A.json',
'Mobilo/D.json',
'Mobilo/N.json',
'Mobilo/S.json'
];
this.src = this.animations[0];
}
lottieViewLoaded(event) {
this._lottieView = <LottieView>event.object;
this._myLottie.loop = false; // to get the completionBlock to fire the animation can not be looping because then it will never "complete"
this._myLottie.completionBlock = bool => {
console.log('lottie animaton complete', bool);
};
}
}
Vue.registerElement(
'LottieView',
() => require('nativescript-lottie').LottieView
);
<template>
<Page class="page">
<StackLayout>
<LottieView height="130" src="PinJump.json" :loop="true" :autoPlay="true" @loaded="lottieViewLoaded"></LottieView>
</StackLayout>
</page
</template>
<script>
export default {
methods: {
lottieViewLoaded(args) {
this._lottieView = args.object;
},
},
data() {
return {
_lottieView: null,
}
}
};
</script>
:fire: You can find animations in the sample-effects
folder.
Place your animation files in the NS app's app/App_Resources/Android/src/main/assets
folder.
Note: In a nativescript-vue project the above folder may not exist. Place the files in platforms/android/app/src/main/assets
.
Place your animations files in your app/App_Resources/iOS/
folder.
Property | Type | Default | Description |
---|---|---|---|
autoPlay | boolean | false | Start LottieView animation on load if true . |
loop | boolean | false | Loop continuously animation if true . |
src | string | null | Animation path to .json file. |
Property | Type | Default | Description |
---|---|---|---|
completionBlock | (boolean) => void | null | Completion block to be executed upon completion of the animation. The animation is considered complete when it finishes playing and is no longer looping. |
duration | number | null | Get the duration of the animation. |
progress | number | 0 | Get/set the progress of the animation. |
speed | number | 1 | Get/set the speed of the animation. |
Method | Return | Parameters | Description |
---|---|---|---|
cancelAnimation | void | None | Pauses the animation for the LottieView instance. |
isAnimating | boolean | None | Returns true if the LottieView is animating, else false. |
playAnimation | void | None | Plays the animation for the LottieView instance. |
playAnimationFromProgressToProgress | void | startProgress, endProgress | Plays the animation for the LottieView instance from the specified start and end progress values (between 0 and 1). |
setColorValueDelegateForKeyPath | void | value, keyPath | Sets the provided color value on each property that matches the specified keyPath in the LottieView instance. |
setOpacityValueDelegateForKeyPath | void | value, keyPath | Sets the provided opacity value (0 - 1) on each property that matches the specified keyPath in the LottieView instance. |
bradmartin | NathanWalker | rhanb | HamdiWanis |
itstheceo | mudlabs |
cd nativescript-lottie && npm run demo.android
(or demo.ios)src
directory of the plugin will sync to the demo app for testing changes.FAQs
NativeScript plugin to expose AirBnB Lottie library
The npm package nativescript-lottie receives a total of 2 weekly downloads. As such, nativescript-lottie popularity was classified as not popular.
We found that nativescript-lottie demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
ESLint now supports HTML linting with 48 new rules, expanding its language plugin system to cover more of the modern web development stack.
Security News
CISA is discontinuing official RSS support for KEV and cybersecurity alerts, shifting updates to email and social media, disrupting automation workflows.
Security News
The MCP community is launching an official registry to standardize AI tool discovery and let agents dynamically find and install MCP servers.