Coder Social home page Coder Social logo

melihberberolu / react-native-shimmer-placeholder Goto Github PK

View Code? Open in Web Editor NEW

This project forked from tomzaku/react-native-shimmer-placeholder

0.0 2.0 0.0 3.52 MB

Placeholder of React Native

License: MIT License

JavaScript 71.04% Python 6.56% Java 5.74% Objective-C 16.66%

react-native-shimmer-placeholder's Introduction

React Native Shimmer Placeholder

Placeholder for both IOS and Android

`

`

Get Started

install size

Installation

Step 1: Install react-native-linear-gradient (dependence)

npm i react-native-linear-gradient --save && react-native link react-native-linear-gradient

or

yarn add react-native-linear-gradient && react-native link react-native-linear-gradient

Step 2: Install this package

npm i react-native-shimmer-placeholder --save

or

yarn add react-native-shimmer-placeholder

That's all!

For who using Expo

Just install direct this package

npm install https://github.com/tomzaku/react-native-shimmer-placeholder.git#expo --save

Usage

Simple

import ShimmerPlaceHolder from 'react-native-shimmer-placeholder'

<ShimmerPlaceHolder autoRun={true} />
<ShimmerPlaceHolder autoRun={true} visible={isFetched}>
  <Text>
    Wow, awesome here.
  </Text>
</ShimmerPlaceHolder>

Connect more components

componentDidMount() {
  this.runPlaceHolder();
}
runPlaceHolder() {
  if (Array.isArray(this.loadingAnimated) && this.loadingAnimated.length > 0) {
    Animated.parallel(
      this.loadingAnimated.map(animate => {
        if (animate&&animate.getAnimated) {
          return animate.getAnimated();
        }
        return null;
      }),
      {
        stopTogether: false,
      }
    ).start(() => {
        this.runPlaceHolder();
    })
  }
}
_renderRows(loadingAnimated, numberRow, uniqueKey) {
  let shimmerRows = [];
  for(let index = 0; index < numberRow; index++ ){
    shimmerRows.push(
      <ShimmerPlaceHolder
          key={`loading-${index}-${uniqueKey}`}
          ref={(ref) => loadingAnimated.push(ref)}
          style={{ marginBottom: 7 }}
      />
    )
  }
  return (
    <View>
      {shimmerRows}
    </View>
  )
}
render() {
  this.loadingAnimated = [];
  return(
    {this._renderRows(this.loadingAnimated, 3, '3rows')}
  )
}

More Detail see this

Props

Prop Description Type Default
visible visible child components boolean false
style Styles applied to the container of Shimmer Placeholder {backgroundColor: '#ebebeb',overflow: 'hidden'}
width With of row number 200
duration Duration of shimmer over a row number 300
height height of row number 15
widthShimmer percent of line placeholder number 0.7
reverse Reverse direction boolean true
autoRun Run shimmer animated at begin boolean false
colorShimmer Color of the shimmer. string ['#ebebeb', '#c5c5c5', '#ebebeb']
backgroundColorBehindBorder If you use border in style you have to set background behide(to force Android work). string 'white'

Methods

Method Description Type
getAnimated get Animated of Placeholder Animated

Contribute

Any help this module will be approciate!

License

MIT

react-native-shimmer-placeholder's People

Contributors

tomzaku avatar trilebks2014 avatar coriou avatar richardlindhout avatar moquez avatar johngoren avatar sibelius avatar

Watchers

James Cloos avatar Melih 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.