0.0.4 • Published 4 years ago

react-native-load-shimmer v0.0.4

Weekly downloads
4
License
MIT
Repository
github
Last release
4 years ago

react-native-load-shimmer

npm.io

Add a simple shimmer effect to any UI loading state. No native dependencies!

Installation

yarn add react-native-load-shimmer

Properties

PropDescriptionRequired
childrenReact native elements that you want to apply a shimmer toY
isShimmeringBoolean - Dictates whether shimmer effect is occurringY
containerStyleStyle to apply to wrapper on shimmer componentN
shimmerConfigConfig object for shimmer effectY

Shimmer Config Options

KeyDescriptionRequiredDefault
skewXSlant applied to shimmerN"-30deg"
gradientWidthWidth of each gradientN20
startXStarting position for shimmer effectNVariable
durationDuration in ms of 1 loop of shimmer effectN1500
useNativeDriverUses the native driver when true.NTrue
shimmerColorColor of shimmer effect. Should match background of screen.Y
toValueEnding position of shimmer effectNVariable
opacityArrArray of opacity values to create shimmerN.05, .15, .25, .3, .35, .3, .25, .15, .05

Usage

/**
 * @flow strict-local
 */

import React from 'react';
import Shimmer from 'react-native-simple-shimmer';

export default function LoadingWithShimmer({children}) {
  const shimmerConfig = {
    startingX: -200,
    useNativeDriver: true,
    shimmerColor: '#FFF',
    toValue: Dimensions.get('window').width + 100,
  };

  return (
      <SafeAreaView>
        <ScrollView
          style={styles.scrollView}>
          <Shimmer shimmerConfig={shimmerConfig} containerStyle={containerStyle} isShimmering={true}>
            {children}
          </Shimmer>
        </ScrollView>
      </SafeAreaView>
  );
};

const styles = StyleSheet.create({
  scrollView: {
    backgroundColor: 'white',
  },
});

License

MIT License. react-native-load-shimmer is under MIT license. © Kevin DeArmond 2020 - present