npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-native-js-shimmer-placeholder

v1.0.7

Published

A Shimmer using React Native Reanimated

Downloads

90

Readme

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

| Prop | Description | Default | | :---------------------------------- | ------------------------------------------------------------------------------------------------- | ----------------------: | | baseColor | The base color of the linear gradient | white | | boomerangMode | After reaching the end of animation, either restart from the beginning or reverse back towards it | false | | canTriggerAnimationCompletion | Conditional trigger of Animation completion (useful for lists) | true | | canUseProc | Should use proc function from reanimated | true | | direction | Sets the direction of the Shimmer to move | Direction.RIGHT | | gradientStyle | Style for the Linear Gradient itself | {} | | highlightColor | The highlight color for the shimmer | rgba(211,211,211,0.5) | | locations | Same as the prop used in Linear Gradient | [0, 0.5, 1] | | onAnimationComplete | Triggers on animation completion | emptyFn | | repeatCount | Number of times to repeat the animation | Depends on show prop | | repeatDelay* | Delay after which the current animation will repeat | 0 | | show | Whether to show the shimmer effect | true | | totalDuration | Duration of the single shimmer cycle | 1500 |

*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

| Prop | Description | Default | | :--------------------------- | ------------------------------------------------------------------------------------- | ---------: | | children | Child to render inside placeholder | null | | childrenWrapperStyle | Wrapper style for the children | {} | | style | Container style for shimmer which wraps the Linear Gradient and the children you pass | {} | | gradientContainerStyle | Container style for gradient | {} | | height | Height of the shimmer | 100% | | width | Width of the Shimmer | Required |

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

Props only for TextPlaceholder

| Prop | Description | Default | | :------------------------ | ---------------------------------------------------------------- | -------------------------: | | children | Text to be shimmered | undefined | | style | Style for the MaskedView | { flex:1 } | | viewBehindMaskStyle | Children of MaskedView which gives the actual color for the Text | { flex:1, width:"100%" } | | textStyle | Style for Text to be rendered | {} | | textColor | Text 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