Giter Club home page Giter Club logo

nativescript-lottie's Introduction

NativeScript-Lottie

NativeScript plugin to expose Airbnb Lottie for awesome animations.

npm npm

Uses Airbnb Lottie for Android and iOS Lottie for iOS.

Demo Screen

The .gif does not do the fluid animations justice

LottieView

Installation

To install execute:

tns plugin add nativescript-lottie

Usage

Plain {N}

XML

<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>

TS

import { LottieView } from "nativescript-lottie";

public yourLoadedEvent(args) {
    this._myLottie: LottieView = args.object; /// this is the instance of the LottieAnimationView
}

{N} with Angular

XML

<StackLayout>
    <LottieView width="100" height="150" [src]="src" [loop]="loop" [autoPlay]="autoPlay" (loaded)="lottieViewLoaded($event)">     </LottieView>
</StackLayout>

Component

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;
    }
}

Assets

โš ๏ธ This plugin uses the nativescript-dev-assets hook to sync the assets files for Android to avoid the following issue.

๐Ÿ”ฅ You can find animations in the sample-effects folder.

Android

Place your animations files in your app/assets folder.

Android

iOS

Place your animations files in your app/App_Resources/iOS/ folder.

iOS

Properties (bindable)

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.

Properties

Property Type Default Description
progress number 0 Get/set the progress of the animation.
speed number 1 Get/set the animation's speed

Methods

Method Return Parameters Description
startAnimation void None Starts the animation for the LottieView instance.
cancelAnimation void None Pauses the animation for the LottieView instance.
isAnimating boolean None Returns true if the LottieView is animating, else false.

Contributors

Brad Martin Nathan Walker Jean-Baptiste Aniel
bradmartin NathanWalker rhanb

nativescript-lottie's People

Contributors

bradmartin avatar nathanwalker avatar rhanb avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.