Giter Site home page Giter Site logo

react-lazy-blur's Introduction

Demo

https://andrusasumets.github.io/react-lazy-blur

Features (1:0:x)

  • Prefetches an image super lazily and then replaces background-image of the component.
  • Uses react-waypoints inside - does not do anything until a user has scrolled to a relevant image.
  • Shows a placeholder images (preferrably blured, see the blurring section) during the load.
  • Uses CSS transitions to make it smooth.
  • Can be used as a wrapper for other content.
  • Includes a complete Webpack example on how to integrate blurred placeholders for dev and production (again, see the blurring section).

Installation

npm install react-lazy-blur

Usage

import ReactLazyBlur from 'react-lazy-blur'

....

<ReactLazyBlur
    background={ 'https://example.com/images/full-size-image.jpg' }
    blur={ 'https://example.com/images/blurred-placeholder.jpg' }
    duration={ 1000 }>

    <YourPrefferedComponent
        ... optionally your content here
    </YourPrefferedComponent>
    
</ReactLazyBlur>

Props

background (string, required): Import an image string and pass it as an argument.
blur : (string, optional) Import a processed and blurred background image and use it as a placeholder while the full-sized image is being prefetched.
duration: (integer, optional) The length of fade after prefetching the image in milliseconds. Defaults to 500ms.
horizontal: (boolean, optional) Trigger prefetching when element is being displayed horizontally. Defaults to false.
children: (component, optional) React.js component or a HTML element.

Blurring

npm install
npm run lazy-blur (Resizes images to have 1280 width and auto height and then uses the converted .lazy files to have separate .blur files. It's up to you if and when you would like to use those images).
npm run dev
npm run build (optional)

License:

Do What the Fuck You Want To Public License

Author:

Andrus Asumets / [email protected] / www.asumets.ee

react-lazy-blur's People

Contributors

andrusasumets avatar

Stargazers

M Haidar Hanif avatar Cat  avatar Rosen Tomov avatar Prathak Paisanwatcharakit avatar Joshua Tuscan avatar amir houieh avatar Malik avatar abdul dakkak avatar Hanik Yadav avatar kitze 🚀 avatar  avatar John Paul Ada avatar Bryan Fillmer avatar Geoff Holden avatar Viljar Kärgenberg avatar Zach Sim avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.