1.1.3 • Published 2 years ago

react-before-after-slider-bousing v1.1.3

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

React before after slider component

Simple slider component for comparing images. Before and after.

screencast demo

Demo

https://smeleshkin.github.io/react-before-after-slider-component/

Build

npm run build:npm

Basic usage

npm install react-before-after-slider-component --save

Then use it in your app:

import React from 'react';
import ReactBeforeSliderComponent from 'react-before-after-slider-component';
import 'react-before-after-slider-component/dist/build.css';

const FIRST_IMAGE = {
  imageUrl: 'https://example.com/.../some-image.jpg'
};
const SECOND_IMAGE = {
  imageUrl: 'https://example.com/.../some-image-2.jpg'
};
/* ... */
<ReactBeforeSliderComponent
    firstImage={FIRST_IMAGE}
    secondImage={SECOND_IMAGE}
/>
/* ... */

Props

AttributeRequiredTypeDefaultDescription
firstImagetrueImageImage object with source url.
secondImagetrueImageImage object with source url.
delimiterColorfalsestringCustom delimiter background color.
currentPercentPositionfalsenumber50Start delimiter position. Or also the current position, if it will change in parent.
classNamefalsestringCustom classname.
withResizeFeelfalsebooleantrueFeeling to window resizing.
onReadyfalsefunctionOn slider ready callback.
onVisiblefalsefunctionOn slider visible in viewport callback.
onChangePercentPositionfalsefunctionOn delimiter position update callback. Has new position parameter.

Specific Types

interface Image {
    imageUrl: string,
    alt?: string,
}