Git Product home page Git Product logo

react-lazy-card's Introduction

#react-lazy-card

A lighweight image lazy-loading component written in React

codecov Build Status npm GitHub license

It supports both manual and automatic image lazy-loading.

Demo is available here.

Installation

npm install --save react-lazy-card

Basic Usage

JSX:

import LazyCard from 'react-lazy-card';

<LazyCard image="b.jpg" autoLoad={true} defaultimage="default2.jpg">Text 2</LazyCard>

CSS

@import "react-lazy-card/dist/slide"

Options

prop default description
className string custom classname for lazy-card component
image string final image to be loaded
defaultImage string pre-loader image to be shown
autoLoad false should the component automatically lazyLoad the image
attributes {} Additional attributes for component root
title '' serves like alt attribute for img tag
lazyLoad true enable/disable lazy load

.load()

If autoload is set to false the you have to manually call .load() to load the image

// This will not load `image` automatically. Will load default1.jpg
const a = <LazyCard image="a.jpg" defaultImage="default1.jpg">Text 1</LazyCard>
a.load() // now image will be loaded

// Alternatively set `autoLoad` to true. So `a.jpg` will automatically replace
// default1.jpg when it is loaded.
<LazyCard image="a.jpg" defaultImage="default1.jpg" autoLoad={true}>Text 1</LazyCard>

Development

git clone https://github.com/housinghq/react-lazy-card
cd react-lazy-card
npm install
npm run storybook

Open an issue before opening a PR. This package is optimised for mobile so its hard to include all the features.

###License MIT @ Loconsolutions

react-lazy-card's People

Contributors

chantastic avatar gaearon avatar ritz078 avatar

Watchers

 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.