• Stars
    star
    281
  • Rank 146,108 (Top 3 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created over 6 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

ReactJS component to make images appear with transition as they load.

react-image-appear icon

react-image-appear npm version NPM Downloads Build Status Patreon donate button

ReactJS component to make images appear with transition as they load.

Wraps an img within a placeholder element and adds a gif loader in between. No more ugly-looking progressively loading images!

react-image-appear

This project has also been ported to AngularJS 1.x - ng-image-appear.


Installation

via npm

npm install react-image-appear --save

via yarn

yarn add react-image-appear

Usage

Import the component and provide the src with any of the available props.

import ReactImageAppear from 'react-image-appear';

<ReactImageAppear 
    src="https://newevolutiondesigns.com/images/freebies/tropical-beach-background-8.jpg"
    animation="zoomIn"
    animationDuration="1s"
/>

Props

src {string} | required

The image source.

<ReactImageAppear 
    src="https://newevolutiondesigns.com/images/freebies/tropical-beach-background-8.jpg"
/>

className {string}

Classes to be applied to the image.

<ReactImageAppear 
    src="https://newevolutiondesigns.com/images/freebies/tropical-beach-background-8.jpg"
    className="my-image"
/>

loader {string}

Adds a custom loader to the component. When not provided, applies a default one.

<ReactImageAppear 
    src="https://newevolutiondesigns.com/images/freebies/tropical-beach-background-8.jpg"
    loader="https://cache.dominos.com/nolo/ca/en/010048/assets/build/images/img/spinner.gif"
/>

loader


loaderStyle {object}

Adds custom styling to the loader.

<ReactImageAppear 
    src="https://newevolutiondesigns.com/images/freebies/tropical-beach-background-8.jpg"
    loaderStyle={{ border: "2px solid red" }}
/>

loaderClass {string}

Adds CSS classes to the loader.

<ReactImageAppear 
    src="https://newevolutiondesigns.com/images/freebies/tropical-beach-background-8.jpg"
    loaderClass="my-loader"
/>

placeholder {boolean | string}

Adds a placeholder background to the component.

<ReactImageAppear 
    src="https://newevolutiondesigns.com/images/freebies/tropical-beach-background-8.jpg"
    placeholder
/>

placeholder

You can override the default placeholder background and add your own by passing an image URL to this prop.

<ReactImageAppear 
    src="https://newevolutiondesigns.com/images/freebies/tropical-beach-background-8.jpg"
    placeholder="http://getuikit.com/docs/images/placeholder_600x400.svg"
/>

placeholder-custom


placeholderStyle {object}

Adds custom styling to the placeholder.

<ReactImageAppear 
    src="https://newevolutiondesigns.com/images/freebies/tropical-beach-background-8.jpg"
    placeholderStyle={{ border: "2px solid red", backgroundColor: 'black' }}
/>

placeholderClass {string}

Adds CSS classes to the placeholder.

<ReactImageAppear 
    src="https://newevolutiondesigns.com/images/freebies/tropical-beach-background-8.jpg"
    loaderClass="my-placeholder"
/>

animation {string} | Default: fadeIn

Add a CSS3 powered animation to the image as it appears.

<ReactImageAppear 
    src="https://newevolutiondesigns.com/images/freebies/tropical-beach-background-8.jpg"
    animation="bounceIn"
/>

animation

react-image-appear has the following built-in CSS3 animations -

fadeIn (default)
fadeInUp
fadeInRight
fadeInDown
fadeInLeft
bounceIn
bounceInUp
bounceInRight
bounceInDown
bounceInLeft
flipInX
flipInY
zoomIn
blurIn
blurInUp
blurInRight
blurInDown
blurInLeft
fillIn

animationDuration {string} | Default: 700ms

Specifies the animation duration for the image to appear.

<ReactImageAppear 
    src="https://newevolutiondesigns.com/images/freebies/tropical-beach-background-8.jpg"
    animation="bounceIn"
    animationDuration="1s"
/>

easing {string} | Default: ease-in-out

Specifies the timing-function for the CSS3 powered animation.

<ReactImageAppear 
    src="https://newevolutiondesigns.com/images/freebies/tropical-beach-background-8.jpg"
    animation="bounceIn"
    easing="ease-in"
/>

showLoader {boolean} | Default: true

Specifies whether to show the loader or not.

<ReactImageAppear 
    src="https://newevolutiondesigns.com/images/freebies/tropical-beach-background-8.jpg"
    showLoader={false}
/>

show-loader


onClick {function}

Callback to be called when the image is clicked.

<ReactImageAppear 
    src="https://newevolutiondesigns.com/images/freebies/tropical-beach-background-8.jpg"
    onClick={handleImageClick}
/>

Testing

ReactImageAppear uses the jest test runner along with enzyme for easier assertion and manipulation. Run the following command to start the jest test runner -

npm test

Contributors


Arun Michael Dsouza


Patrick


Stefan


Tim Carr


Support

If you'd like to help support the development of the project, please consider backing me on Patreon -


License

MIT Licensed

Copyright (c) 2018 Arun Michael Dsouza ([email protected])

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

More Repositories

1

tensorflow-image-detection

A generic image detection program that uses Google's Machine Learning library, Tensorflow and a pre-trained Deep Learning Convolutional Neural Network model called Inception.
Python
330
star
2

CSS-Mint

Lightweight and simple to use UI Kit. Fully responsive, just 3KB gzipped.
CSS
212
star
3

joypad.js

JavaScript library that lets you connect and use various gaming controllers with browsers that support the Gamepad API. Less than 5KB in size with zero dependencies and support for button press, axis movement events and vibration play effect.
JavaScript
152
star
4

ng-youtube-embed

AngularJS module to embed Youtube videos with support for Youtube player parameters and JavaScript API for iframe embeds. Superlight (less than 5KB) and easy to use! Supports Youtube video URLs and IDs. No 3rd party JS dependencies.
JavaScript
143
star
5

ng-image-appear

AngularJS Module to make images appear with transition as they load.
JavaScript
121
star
6

picla

jQuery plugin that converts Alt-texts into simple image labels
JavaScript
95
star
7

pineapple-sass

A must-have Sass mixin library for all your Sassy needs
CSS
46
star
8

bootstrap-football-homepage

A minimal Bootstrap 3 one page Theme for Football lovers
HTML
39
star
9

ng-textarea-enter

Execute a function on pressing the enter key in a textarea.
JavaScript
37
star
10

D_Pad

Drumming App built with Processing 2, for Desktop/Mobile Environments.
Processing
25
star
11

Zeta

Zeta is a command interpreter built purely in C for Windows OS
C
11
star
12

JSConf-belgium-2017-talk

Slides and demos for my JSConf Belgium 2017 talk.
JavaScript
7
star
13

meteor-discussion-board

Discussion Board app built with Meteor js
JavaScript
6
star
14

arunmichaeldsouza.com

My Personal Website
JavaScript
5
star
15

tuneshuffle

Web-based localised music player. Start a server locally, ask your friends to join in, share and stream music together!
JavaScript
5
star
16

JSConf-iceland-2018-talk

Slides for my JSConf Iceland 2018 talk.
3
star
17

node-instagram-app

Simple app built with Node to display popular images from Instagram
CSS
3
star
18

javascript-and-friends-2020-talk

Slides for my JavaScript & Friends Conference 2020 talk.
3
star
19

javascript-30-course

Solutions for the JavaScript 30 Day Challenge by Wes Bos
HTML
3
star
20

viewport-ratio-js

Script to get ratio of visible area of selected elements in the viewport.
JavaScript
2
star
21

simple-node-server

Simplest node server to serve static files using express
JavaScript
2
star
22

javascript-foundations

JS algorithmic practice problems
JavaScript
1
star
23

react-foundations

Playing around with React JS
JavaScript
1
star
24

isomorphic-react

Experimenting with Isomorphic ReactJS
JavaScript
1
star
25

es-foundations

Playing around with ECMAScript - ES6, ES8
JavaScript
1
star