Socket
Socket
Sign inDemoInstall

react-native-js-shimmer-placeholder

Package Overview
Dependencies
523
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    react-native-js-shimmer-placeholder

A Shimmer using React Native Reanimated


Version published
Weekly downloads
13
increased by225%
Maintainers
1
Created
Weekly downloads
 

Readme

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
  1. Do not use for more than 5 number of list item because of this react-native-reanimated limitation https://github.com/software-mansion/react-native-reanimated/issues/782
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

FAQs

Last updated on 20 Aug 2020

Did you know?

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc