You're Invited: Meet the Socket team at BSidesSF and RSAC - April 27 - May 1.RSVP
Socket
Sign inDemoInstall
Socket

react-native-js-shimmer-placeholder

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-js-shimmer-placeholder

A Shimmer using React Native Reanimated

1.0.7
latest
Source
npm
Version published
Weekly downloads
13
30%
Maintainers
1
Weekly downloads
 
Created
Source

react-native-js-shimmer-placeholder

Shimmering effect using react-native-reanimated, react-native-linear-gradient and react-native-masked-view

Demo

Demo of React Native JS Shimmer Placeholder

Installation

Make sure you have already installed react-native-reanimated, react-native-linear-gradient and react-native-masked-view or install it from their links

npm install react-native-js-shimmer-placeholder --save

or using yarn

yarn add react-native-js-shimmer-placeholder

Usage

To use shimmering effect for View

import {
  ViewPlaceholder,
  Direction,
} from "react-native-js-shimmer-placeholder";

<ViewPlaceholder
  show={true}
  width={100}
  height={100}
  style={{
    borderWidth: 1,
    borderColor: "lightgrey",
    borderRadius: 50,
  }}
  direction={Direction.UP}
  gradientContainerStyle={{ borderRadius: 50 }}
>
  <View
    style={{
      height: 100,
      backgroundColor: "#318fb5",
      borderRadius: 50,
      alignItems: "center",
      justifyContent: "center",
    }}
  >
    <Text style={{ fontSize: 30 }}>🚀</Text>
  </View>
</ViewPlaceholder>;

To use shimmering effect for Text

import { TextPlaceholder } from "react-native-js-shimmer-placeholder";

<TextPlaceholder
  show={true}
  textStyle={{ fontSize: 24, fontWeight: "bold" }}
  style={{
    flex: 1,
    width: "100%",
    justifyContent: "center",
    alignItems: "center",
  }}
  textColor={"#318fb5"}
>
  Hey React Native devs!
</TextPlaceholder>;

Properties

Common props for both ViewPlaceholder and TextPlaceholder
PropDescriptionDefault
baseColorThe base color of the linear gradientwhite
boomerangModeAfter reaching the end of animation, either restart from the beginning or reverse back towards itfalse
canTriggerAnimationCompletionConditional trigger of Animation completion (useful for lists)true
canUseProcShould use proc function from reanimatedtrue
directionSets the direction of the Shimmer to moveDirection.RIGHT
gradientStyleStyle for the Linear Gradient itself{}
highlightColorThe highlight color for the shimmerrgba(211,211,211,0.5)
locationsSame as the prop used in Linear Gradient[0, 0.5, 1]
onAnimationCompleteTriggers on animation completionemptyFn
repeatCountNumber of times to repeat the animationDepends on show prop
repeatDelay*Delay after which the current animation will repeat0
showWhether to show the shimmer effecttrue
totalDurationDuration of the single shimmer cycle1500

*Set canUseProc prop to true for the maximum number of items with same repeatDelay and false to others if you use different repeatDelay's.

Props only for ViewPlaceholder
PropDescriptionDefault
childrenChild to render inside placeholdernull
childrenWrapperStyleWrapper style for the children{}
styleContainer style for shimmer which wraps the Linear Gradient and the children you pass{}
gradientContainerStyleContainer style for gradient{}
heightHeight of the shimmer100%
widthWidth of the ShimmerRequired

To pass View props just pass the props as you do for a View Component

Props only for TextPlaceholder
PropDescriptionDefault
childrenText to be shimmeredundefined
styleStyle for the MaskedView{ flex:1 }
viewBehindMaskStyleChildren of MaskedView which gives the actual color for the Text{ flex:1, width:"100%" }
textStyleStyle for Text to be rendered{}
textColorText color of the children#5F717B

To pass Text Props just pass the props as you do for a Text Component

Limitation
TODO List
  • Adding support for Reanimated 2 which will solve the above mentioned limitation
Contribution

Any help to improve the module is appreciated

LICENSE

react-native-js-shimmer-placeholder is licensed under The MIT License

Keywords

react

FAQs

Package last updated on 20 Aug 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts