Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/magicoder10/react-progressive-image

Progressive image loading component for React
https://github.com/magicoder10/react-progressive-image

javascript-library progressive-image progressive-image-loading react reactjs

Last synced: 9 days ago
JSON representation

Progressive image loading component for React

Awesome Lists containing this project

README

        

# React Progressive Image
Progressive image loading component for React

[![Build Status](https://travis-ci.com/byliuyang/react-progressive-image.svg?branch=master)](https://travis-ci.com/byliuyang/react-progressive-image)

## Preview
![Progressive Image Loading](screenshots/1.gif)

## Features
- Lazy load image when it's visible in the viewport
- Progressively load image with animation

## Future plan
- [In Progress] Build a website to help people generate thumbnail from the original image.
- Provide hosting service for both image assets.
- Generate React & Angular progressive image loading code based on the hosted URLs.

## Usage

Install npm package

```
yarn add @time4hacks/react-progressive-image
```

Import `Progressive Image Component`, `BrowserImageLoader`, and `BrowserViewport`:

```typescript
import {
ProgressiveImage,
BrowserImageLoader,
BrowserViewport
} from '@time4hacks/react-progressive-image';
```

Initialize Viewport and ImageLoader

```typescript
const imageLoader = new BrowserImageLoader();
const viewport = new BrowserViewport();
```
Add progressive image to your app:

```typescript

```

Replace `photoThumbnail` with the URL of thumbnail and `photo` with the URL of full resolution image.
Please remember to update `alt` to improve accessibility.

## Development
Install library dependencies

```
yarn
```

Start library live re-bundle server
```
yarn start
```

Install example dependencies and link library

```
cd example
yarn
```

Start live reload web server
```
yarn start
```

## Testing
### Running unit tests
```
yarn test
```

## Author
- **Harry Liu** - *Initial work* - [byliuyang](https://github.com/byliuyang)

## License
This library is maintained under the MIT License.