Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

🍭 A React Native Loader Component which uses Airbnb's Lottie for beautiful loader animations.

License

NotificationsYou must be signed in to change notification settings

vikrantnegi/react-native-animated-loader

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

46 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Read more about this packagehere.

downloadsnpm-versiongithub-taglicense

A React Native Loader Component which uses Airbnb'sLottie for beautiful loader animations.

     

Prerequisites

Using React Native CLI

This library useslottie-react-native to render loader animations. Therefore this library need to be installed and linked to your project before installing this package.

Follow the official instruction and linking guidehere.

Using Expo

No need to do anything specific, just install the package itself. Expo already has Lottie library API available and it will take care of the rest.

Install

yarn add react-native-animated-loader

or

npm install react-native-animated-loader --save

Usage

Class Component

importReactfrom'react';import{StyleSheet,Text}from'react-native';importAnimatedLoaderfrom"react-native-animated-loader";exportdefaultclassLoaderextendsReact.Component{constructor(props){super(props);this.state={visible:false};}componentDidMount(){setInterval(()=>{this.setState({visible:!this.state.visible});},2000);}render(){const{ visible}=this.state;return(<AnimatedLoadervisible={visible}overlayColor="rgba(255,255,255,0.75)"source={require("./loader.json")}animationStyle={styles.lottie}speed={1}><Text>Doing something...</Text></AnimatedLoader>);}}conststyles=StyleSheet.create({lottie:{width:100,height:100}});

Functional Component

importReact,{useState,useEffect}from'react';import{StyleSheet,Text}from'react-native';importAnimatedLoaderfrom'react-native-animated-loader';exportdefaultfunctionApp(){const[visible,setVisible]=useState(false);useEffect(()=>{setInterval(()=>{setVisible(!visible);},2000);},[]);return(<AnimatedLoadervisible={visible}overlayColor="rgba(255,255,255,0.75)"animationStyle={styles.lottie}speed={1}><Text>Doing something...</Text></AnimatedLoader>);}conststyles=StyleSheet.create({lottie:{width:100,height:100,},});

Usage in Expo

Example for expo projects

Loader files

You can find free lottie files for your loadershere.

Props

PropDescriptionDefault
sourceThe source of animation. Can be referenced as a local asset by a string, or remotely with an object with auri property, or it can be an actual JS object of an animation, obtained (for example) with something likerequire('../path/to/animation.json').Lottie Object
visibleControls the visibility of the loader.false
overlayColorChanges the color of the overlay.rgba(255,255,255,0.75)
animationStyleThe style to be applied to the Lottie.-
animationTypeChanges animation on show and hide loader's view.none
speedThe speed the animation will progress.1
loopA boolean flag indicating whether or not the animation should loop.true

Work in Progress

  • Add expo example
  • Add ability to render text with animations
  • Add test cases

License

Licensed under theMIT.

Donation

If this project helped you reduce time to develop, please consider buying me a cup of coffee :)

Buy Me A Coffee

ko-fi

Sponsor this project

    Packages

    No packages published

    Contributors7


    [8]ページ先頭

    ©2009-2025 Movatter.jp