1.1.0 • Published 6 years ago

background-image-on-load v1.1.0

Weekly downloads
217
License
MIT
Repository
github
Last release
6 years ago

Background-Image-On-Load

A simple way to check background-image is loaded.

Installation

npm:

npm install background-image-on-load --save	

yarn:

yarn add background-image-on-load	

Usage

import React, { Component } from 'react';	
import BackgroundImageOnLoad from 'background-image-on-load';	
 class App extends Component {	
   state = {	
    bgIsLoaded: false	
  };	
  	
  render() {	
    const { bgIsLoaded } = this.state;	
    return (	
        <div	
          style={{ 	
            height: 300,	
            backgroundPosition: 'center',	
            backgroundSize: 'cover',	
            backgroundImage: `url(${!bgIsLoaded ? 'https://picsum.photos/310/310?blur' : 'https://picsum.photos/1600/310'})`	
          }}	
        >	
          <BackgroundImageOnLoad	
            src={'https://unsplash.it/1200/310?random'}	
            onLoadBg={() =>	
              this.setState({	
              bgIsLoaded: true	
            })}	
            onError={err => console.log('error', err)}	
          />	
        </div>	
    );	
  }	
}	
 export default App;	
1.1.0

6 years ago

0.1.6

7 years ago

0.1.5

7 years ago

0.1.4

7 years ago

0.1.3

8 years ago

0.1.2

8 years ago

0.1.1

8 years ago

0.1.0

8 years ago