0.1.5 • Published 5 years ago

react-image-comparison v0.1.5

Weekly downloads
3
License
MIT
Repository
github
Last release
5 years ago

React Compare Image

All Contributors

Simple React component to compare two images using slider.

img

NOTE: Vue.js Version is also available!

Demo

DEMO

Install

yarn add react-compare-image

Note: use v0.*.* If you are using React v.16.7 or older.

yarn add react-compare-image@^0.8.2

Features

  • Simple
  • Responsive (fit to the parent width)
  • Size difference between two images handled correctly. Element size determined by following two factors:
    • width of the parent
    • right image's aspect ratio

How to use

yarn add react-compare-image

// or

npm install --save react-compare-image
import ReactCompareImage from 'react-compare-image';

<ReactCompareImage leftImage="image1.jpg" rightImage="image2.jpg" />;

Props

Prop (* required)typedefaultdescription
leftImage *stringnullleft image's url
rightImage *stringnullright image's url
sliderPositionPercentagenumber (float)0.5Default line position (from 0 to 1)
sliderLineWidthnumber (px)2line width of slider (by pixel)
sliderLineColorstring"#ffffff"line color of slider
leftImageAltstring''alt props for left image
rightImageAltstring''alt props for right image
leftImageCssobject{}Additional css for left image
rightImageCssobject{}Additional css for right image
leftImageLabelstringnull(>=v1.2.0) Label for the image (e.g. before)
rightImageLabelstringnull(>=v1.2.0) Label for the image (e.g. after)
handleelementnull(>=v1.2.0) Custom handle element. Just pass <React.Fragment /> if you want to remove handle.
handleSizenumber (px)40diameter of slider handle (by pixel)
hoverbooleanfalseWhether to slide at hover
skeletonelementnullElement displayed while image is loading
autoReloadSpannumber (ms)nullIf specified, the image is loaded again at the interval specified when loading images failed
autoReloadLimitnumber (count)10Limitation on automatic reload retry count
onSliderPositionChangefunctionnullCallback function called each time the slider changes. The position (0 to 1) of the slider is passed as arg

Dependencies

Contributors

0.1.5

5 years ago

0.1.4

5 years ago

0.1.3

5 years ago

0.1.2

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago

0.0.9

5 years ago

0.0.8

5 years ago

0.0.7

5 years ago

0.0.6

5 years ago

0.0.5

5 years ago

0.0.4

5 years ago

0.0.3

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago