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-animated-placeholder-image

v1.0.1

Published

[![npm version](https://badge.fury.io/js/react-native-animated-placeholder-image.svg)](https://badge.fury.io/js/react-native-animated-placeholder-image) [![License: MIT](https://img.shields.io/badge/License-MIT-brightgreen.svg)](https://opensource.org/li

Downloads

16

Readme

react-native-placeholder-image

npm version License: MIT

This component can be used to show a default placeholder image while loading images from network in React Native. It serves as a way to display default images on both Android and iOS similar to how React Native uses defaultSource for iOS.

In the above examples the images at the top of the preview are all animated and reveal on load with a fading effect, the ones at the bottom are not animated and simply replace the placeholder with the loaded image.

Installation

Run the following command

npm i react-native-animated-placeholder-image

Props

Required

imageURL

The url to be used to load the image.

placeholder

This needs to be a local image object ( do not pass the path to the image, import it and pass the reference ). This will be used as the placeholder for the netowrk image.

imageStyle

This will modify the main image ( and placeholder if a placeholder style is not passed ). Use this to pass a fixed width and height which is required for network images.

isAnimatedReveal

Boolean flag used to decide whether or not the fading animation is to be used when the image loads.

Optional

containerStyle

You can additionally provide a separate style object for the container in case you need to provide separate styling. By default the container style is set to an empty object with flex: 1 appended to it. Note that any style you pass, flex: 1 will be appended to it.

isBackground

If you need to use this image component as an ImageBackground tag you have to set this prop to true otherwise any children passed will be ignored. Note this has not been fully tested so it might not work as intended, please use the issues section of the repository to report any fixes if needed.

resizeMode

By default the resizeMode for android is set to 'cover', if you need to change this use this prop to pass a valid resizeMode value. Refer to the react native documentation for a list of valid values and expected behaviours.

placeholderStyle

An optional style prop to be used in case you want to style your placeholder separately. By default the placeholder uses the same object passed for the imageStyle.

revealDuration

Value in milliseconds that is used for the fading animation. If isAnimatedReveal is set to false this value is ignored. If a value less than 300 milliseconds is provided, it will be replaced with 300. By default the reveal duration is set to 1000.

Example

For example the two images displayed in the preview with the movie poster above is rendered using the follwoing code.

/**
@flow
 */
import React from 'react';
import { View } from 'react-native';
import ImageWithPlaceholder from '../../src';
import placeholder from './images/camera-placeholder.png';

const MovieExample = () => {
    return (
        <View style={ { flex: 1, marginLeft: 50, marginTop: 20 } } >
            <View style={ { flex: 1 } } >
                <ImageWithPlaceholder
                    placeholder={ placeholder }
                    containerStyle={ {} }
                    imageStyle={ {
                        width: 150,
                        height: 200,
                        borderRadius: 30,
                    } }
                    isAnimatedReveal
                    imageURL={ 'https://image.tmdb.org/t/p/original/7WsyChQLEftFiDOVTGkv3hFpyyt.jpg' }
                />
            </View>

            <View style={ { flex: 1 } } >
                <ImageWithPlaceholder
                    placeholder={ placeholder }
                    containerStyle={ {} }
                    imageStyle={ {
                        width: 150,
                        height: 200,
                        borderRadius: 30,
                    } }
                    isAnimatedReveal={ false }
                    imageURL={ 'https://image.tmdb.org/t/p/original/7WsyChQLEftFiDOVTGkv3hFpyyt.jpg' }
                />
            </View>
        </View>
    );
};

export default MovieExample;

This example along with the other two can be found in the examples folder in the repository.