•  


GitHub - nativescript-community/ui-lottie: NativeScript plugin to expose Airbnb Lottie
Skip to content

nativescript-community/ui-lottie

Repository files navigation

NativeScript plugin to expose Airbnb Lottie for awesome animations.

npm npm Action Build stars donate

Changelog

All notable changes to this project will be documented in the changelog .

Demo Screen

The .gif does not do the fluid animations justice

LottieView

Installation

To install execute:

tns plugin add @nativescript-community/ui-lottie

Usage

NativeScript (Core)

XML

<
Page

    xmlns
=
"
http://schemas.nativescript.org/tns.xsd
"

    xmlns
:
Lottie
=
"
@nativescript-community/ui-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-community/ui-lottie"
;


public
 yourLoadedEvent
(
args
)
 {

    this
.
_myLottie
 =
 args
.
object
 as
 LottieView
;
 /// this is the instance of the LottieAnimationView

}

NativeScript Angular

Module

First you need to include the NativeScriptLottieModule in your app.module.ts

import
 {
 NativeScriptLottieModule
}
 from
 '@nativescript-community/ui-lottie/angular'
;


@
NgModule
(
{

    imports
: 
[

        NativeScriptLottieModule

    ]
,

    ...
}
)

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
 {
 LottieView
 }
 from
 '@nativescript-community/ui-lottie'
;


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

  }

}

NativeScript Vue

Bootstrap

If you want to use this plugin with Vue, do this in your app.js or main.js :

import
 LottieView
 from
 '@nativescript-community/ui-lottie/vue'
;


Vue
.
use
(
LottieView
)
;

This will install and register LottieView component to your Vue instance and now you can use the plugin.

Component

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

Assets

?? You can find animations in the sample-effects folder.

Android

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 .

iOS

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

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

Methods

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).
setColor void value, keyPath Sets the provided color value on each property that matches the specified keyPath in the LottieView instance.
setOpacity void value, keyPath Sets the provided opacity value (0 - 1) on each property that matches the specified keyPath in the LottieView instance.

Contributors

Brad Martin Nathan Walker Jean-Baptiste Aniel HamdiWanis
bradmartin NathanWalker rhanb HamdiWanis
itstheceo itstheceo
itstheceo mudlabs
- "漢字路" 한글한자자동변환 서비스는 교육부 고전문헌국역지원사업의 지원으로 구축되었습니다.
- "漢字路" 한글한자자동변환 서비스는 전통문화연구회 "울산대학교한국어처리연구실 옥철영(IT융합전공)교수팀"에서 개발한 한글한자자동변환기를 바탕하여 지속적으로 공동 연구 개발하고 있는 서비스입니다.
- 현재 고유명사(인명, 지명등)을 비롯한 여러 변환오류가 있으며 이를 해결하고자 많은 연구 개발을 진행하고자 하고 있습니다. 이를 인지하시고 다른 곳에서 인용시 한자 변환 결과를 한번 더 검토하시고 사용해 주시기 바랍니다.
- 변환오류 및 건의,문의사항은 juntong@juntong.or.kr로 메일로 보내주시면 감사하겠습니다. .
Copyright ⓒ 2020 By '전통문화연구회(傳統文化硏究會)' All Rights reserved.
 한국   대만   중국   일본