Skip to content
NativeScript plugin to use native gifs
TypeScript JavaScript Ruby
Branch: master
Clone or download
Pull request Compare This branch is 2 commits ahead, 13 commits behind bradmartin:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
demo
images
src
.gitignore
.prettierrc
README.md
tslint.json

README.md

NativeScript-Gif

NativeScript plugin to use GIFs in your application.

npm npm stars forks license donate nStudio banner

Do you need assistance on your project or plugin? Contact the nStudio team anytime at team@nstudio.io to get up to speed with the best practices in mobile and web app development.


Installation

NS 4X

tns plugin add nativescript-gif

NS 3x

tns plugin add nativescript-gif@3.1.1

NS 2x

tns plugin add nativescript-gif@1.0.9


The native libraries used to handle rendering GIFs for Android & iOS.

Android Library iOS CocoaPod
Koral-- / android-gif-drawable FLAnimatedImage by Flipboard
Android Screen iOS Screen
GifExample iOSSample

Usage

Plain NativeScript

IMPORTANT: Make sure you include xmlns:Gif="nativescript-gif" on the Page element.

<Page xmlns="http://schemas.nativescript.org/tns.xsd"
      xmlns:Gif="nativescript-gif" loaded="pageLoaded">
  <StackLayout>
    <Gif:Gif headers="{{headersJSON}}" src="~/gifs/bill.gif" height="100" />
    <Gif:Gif src="https://media4.giphy.com/media/3uyIgVxP1qAjS/200.gif" height="200" />
  </StackLayout>
</Page>

Angular NativeScript

import { registerElement } from "nativescript-angular/element-registry";
import { Gif } from "nativescript-gif";
registerElement("Gif", () => Gif);
HTML
<StackLayout>
    <Gif [headers]="headersJSON" src="~/gifs/bill.gif" height="100" ></Gif>
    <Gif src="https://media4.giphy.com/media/3uyIgVxP1qAjS/200.gif" height="200" ></Gif>
</StackLayout>

Properties

  • src - required Set the gif file to play.

  • headers - (JSON Object) - optional Set headers to add when loading a gif from URL

API

start()
  • starts playing the .gif
stop()
  • stops playing the .gif
getFrameCount()
  • returns the number of frames in the current .gif
isPlaying()
  • returns boolean value indicating if the gif is playing.

Android Only
getDuration()
  • returns the .gif duration
reset()
  • resets the .gif to its initial frame
setSpeed(speedFactor: Number)
  • sets the .gif play speed
recycle()
  • provided to speed up freeing memory advanced usage - you shouldn't need this often

Contributors

You can’t perform that action at this time.