timbru31 / cordova-plugin-lottie-splashscreen

🐣 🎬 📱 Apache Cordova plugin to show Lottie animations as the splash screen with Airbnb's Lottie wrapper
https://www.npmjs.com/package/cordova-plugin-lottie-splashscreen
MIT License
132 stars 54 forks source link
airbnb-lottie android bodymovin cordova cordova-plugin cordova-plugin-splashscreen hacktoberfest ionic ionic-plugin ios kotlin lottie lottie-android lottie-animation lottie-ios phonegap phonegap-plugin splash-screen swift typescript

cordova-plugin-lottie-splashscreen

Run a security audit Linting Smoke test on Ubuntu (Apache Cordova) Smoke test on Ubuntu (Ionic) Smoke test on macOS Smoke test on Windows

dependency Status Known Vulnerabilities

Commitizen friendly License npm

Apache Cordova plugin to show bodymovin/Lottie animations as the splash screen with Airbnb's Lottie wrapper

Supported platforms

Planned platforms

Prerequisites/Warnings

iOS

You need to have CocoaPods installed because lottie-ios is fetched from there.

$ sudo gem install cocoapods
$ pod setup
Caveats

Only cordova >= 9.0.0 and cordova-ios >= 5.0.0 are supported.
You need to specify a valid SwiftVersion (minimum is 5.5) in your config.xml. (see https://cordova.apache.org/docs/en/latest/config_ref/)

Android

AndroidX and Kotlin support is required. Therefore only cordova-android >= 9.0.0 is supported.
If you use cordova-android <10.0.0 then you need to enable Kotlin and AndroidX in your config.xml by setting GradlePluginKotlinEnabled and AndroidXEnabled to true.
In the FAQ are some examples with common error messages and how to fix them.

Installation

from npm (recommended)

$ cordova plugin add cordova-plugin-lottie-splashscreen

from git (unstable)

$ cordova plugin add https://github.com/timbru31/cordova-plugin-lottie-splashscreen.git

Usage

This Apache Cordova plugin is meant as a replacement for the stock cordova-plugin-splashscreen.
An example project can be found in the example folder.

Methods

lottie.splashscreen.hide

This methods hides the current active Lottie splashscreen and destroys the views. Returns a Promise which is resolved with "OK" in the success case or the error message when it's failed.

await lottie.splashscreen.hide();
lottie.splashscreen.show

This method shows a Lottie splash screen. If no arguments are given, it defaults to the config.xml values, however you can pass (new) options here to change the behavior on runtime. Returns a Promise which is resolved with "OK" in the success case or the error message when it's failed. (For easier reading the TypeScript notation is used)

await lottie.splashscreen.show(location?: string, remote?: boolean, width?: number, height?: number)
lottie.splashscreen.on

This method listens to custom lottie events that are dispatched from the native side and invokes a configured callback function. If the event parameter is a falsy value, such as null or "", the method will listen to all Lottie events. (For easier reading the TypeScript notation is used)

type LottieEvent = 'lottieAnimationStart' | 'lottieAnimationEnd' | 'lottieAnimationCancel' | 'lottieAnimationRepeat';

lottie.splashscreen.on(event: LottieEvent, callback: (ev: Event) => void);
lottie.splashscreen.once

This method listens to a custom lottie event once and resolves the Promise once the event has been called. (For easier reading the TypeScript notation is used)

type LottieEvent = 'lottieAnimationStart' | 'lottieAnimationEnd' | 'lottieAnimationCancel' | 'lottieAnimationRepeat';

await lottie.splashscreen.once(event: LottieEvent).then(event => console.log(event));

Preferences

    <preference name="LottieRemoteEnabled" value="true" />
    <preference name="LottieAnimationLocationLight" value="https://assets.lottiefiles.com/datafiles/99nA1a7mkSF3Oz8/data.json" />
    <preference name="LottieAnimationLocationDark" value="https://assets.lottiefiles.com/datafiles/99nA1a7mkSF3Oz8/data.json" />
    <preference name="LottieAnimationLocation" value="https://assets.lottiefiles.com/datafiles/99nA1a7mkSF3Oz8/data.json" />
    <preference name="LottieImagesLocation" value="www/lottie/images" />
    <preference name="LottieCancelOnTap" value="true" />
    <preference name="LottieHideTimeout" value="?" /> <!-- CAUTION: iOS reads this value in **SECONDS**, Android reads this value in **MILLISECONDS**>
    <preference name="LottieBackgroundColorLight" value="#fff000a3" />
    <preference name="LottieBackgroundColorDark" value="#fff000a3" />
    <preference name="LottieBackgroundColor" value="#fff000a3" />
    <preference name="LottieWidth" value="750" />
    <preference name="LottieHeight" value="750" />
    <preference name="LottieRelativeSize" value="true" />
    <preference name="LottieFullScreen" value="true" />
    <preference name="LottieLoopAnimation" value="true" />
    <preference name="LottieAutoHideSplashScreen" value="true" />
    <preference name="LottieEnableHardwareAcceleration" value="true" />
    <preference name="LottieScaleType" value="CENTER_CROP" />
    <preference name="LottieFadeOutDuration" value="?" /> <!-- CAUTION: iOS reads this value in **SECONDS**, Android reads this value in **MILLISECONDS**>
    <preference name="LottieHideAfterAnimationEnd" value="true" />
    <preference name="LottieCacheDisabled" value="true" />

Built by (c) Tim Brust and contributors. Released under the MIT license.