1.8.4 • Published 4 years ago

react-image-comparison-slider v1.8.4

Weekly downloads
249
License
MIT
Repository
-
Last release
4 years ago

Node.js CI

Installation

npm install react-image-comparison-slider

or

yarn add react-image-comparison-slider

Usage

import ImageSlider from "react-image-comparison-slider";

<div style={{ width: 700, height: 450 }}>
    <ImageSlider
        image1=""
        image2=""
        onSlide={() => {
          console.log("sliding");
        }}
    />
</div>

Props

PropsTypeDefaultDescription
image1string-First image's source (URL, base64 string etc.)
image2string-Second image's source (URL, base64 string etc.)
alt1string"alt1"First image's alt text
alt2string"alt2"Second image's alt text
sliderColorstring"red"Slider's color. Should be valid CSS color expression.
sliderWidthnumber3Slider's width in pixel.
showHandlebooleantrueIf false, hides slider handle.
handleBackgroundColorstring"white"Background color of the slider's handle.
handleColorstring"red"Background color of the triangles on the slider's handle.
customHandleDOM ElementnullRenders the passed DOM element as a slider handle.
sliderInitialPositionnumber0.5Slider's initial position between 0 and 1.
leftLabelTextstringnullA label for the first image.
rightLabelTextstringnullA label for the second image.
showPlaceholderbooleantruePlaceholder is shown while waiting for full image to load
customPlaceholderDOM ElementnullPass your custom placeholder component/element.

Callbacks

PropsTypeDefaultDescription
onSlidefunction-A callback function which is invoked on slider's position change.
onSlideEndfunction-A callback function which is invoked on mouseUp at the end of sliding.
onLoadFirstImagefunction-Is invoked when the first image has finished loading.
onLoadSecondImagefunction-Is invoked when the second image has finished loading.
onErrorFirstImagefunction-Is invoked when an error occurs loading the first image.
onErrorSecondImagefunction-Is invoked when an error occurs loading the second image.

Animation

PropsTypeDefaultDescription
animatebooleanfalseAnimates slider.
animationCycleDurationnumber5000Duration of animation in miliseconds.
1.8.4

4 years ago

1.8.3

4 years ago

1.8.2

4 years ago

1.8.1

4 years ago

1.7.1

4 years ago

1.7.0

4 years ago

1.6.0

4 years ago

1.5.0

4 years ago

1.4.1

4 years ago

1.2.0

4 years ago

1.4.0

4 years ago

1.3.0

4 years ago

1.1.5

4 years ago

1.1.1

4 years ago

1.0.2

4 years ago

1.1.0

4 years ago

1.1.4

4 years ago

1.1.3

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago