0.1.44 • Published 6 years ago

react-native-comparison-slider v0.1.44

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

React Native Comparison SLider

  • A simple component to display two image in comparison with a slide-over feature.
  • Help you to compare two images
  • Lightweight, fast, flexible, customizable.
  • Support both iOS and Android devices

Install

npm install --save react-native-comparison-slider

Require React-Native > 0.45.0

Demo

Demo

Example code

PS: For a more detailed example, see: react-native-comparison-slider-example -> to run the example, cd to the example folder and do react-native start lunch the iOS simulator by running react-native run-ios

When you want to use the comparison slider with local images, simply add these lines:

import ComparisonSlider from "react-native-comparison-slider";

<ComparisonSlider
imageWidth={667}
imageHeight={400}
initialPosition={50}
leftImage={require("./img/left.jpeg")}
rightImage={require("./img/right.jpeg")}
/>

These code will use the left.jpeg image as the left image and the right.jpeg as the right image. The slider will be half between the image (50). The imageWidth and imageHeight are the size you want your comparison slider to be.

When you want to use the comparison slider with remote images, simply add these lines:

import ComparisonSlider from "react-native-comparison-slider";

<ComparisonSlider
initialPosition={50}
leftImageURI="https://..."
rightImageURI="https://..."
/>

These code will use the leftImageURI as the left image and the rightImageURI as the right image. The slider will be half between the image (50). The default size for the comparison slider will be the image size of the remote url.You can bypass the size by adding the two props: imageWidth and imageHeight.

Props

PropDescriptionDefault value
initialPositionThe initial position of the slider hover the image. Value are from (0 to 100)50
imageWidthWidth of the image/comparison sliderIf local image: no default value. If remote image image width
imageHeightHeight of the image/comparison sliderIf local image: no default value. If remote image image height
leftImageLeft image for the comparison slider. Use as require()No default value
rightImageRight image for the comparison slider. Use as require()No default value
leftImageURIURL for the left image of the comparison slider. Use as { uri: "http://..." }No default value
rightImageURIURL for the left image of the comparison slider. Use as { uri: "http://..." }No default value
onValueChangeFunction that get called when the slider value changed. (value) => console.log(value)No default value
onSlidingStartFunction that get called when the slider starts to change. () => console.log(value)No default value
onSlidingCompleteFunction that get called when the slider ends changing. () => console.log(value)No default value
thumbnailRenderFunction that return a view. The view will be the middle sliderSlider you can see in the demo
thumbnailWidthWidth of the view that is returned by the thumbnailRenderNo default value
imageStyleStyle property you can pass to apply to image of the comparison sliderNo default value
resizeModeResizeMode property to apply to the image of the comparison sliderNo default value

License

MIT License

Copyright (c) 2017 Charles-Olivier Demers

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Other

This package use these two libraries:

@copyright of the image used in the demo:

0.1.44

6 years ago

0.1.43

6 years ago

0.1.42

6 years ago

0.1.41

7 years ago

0.1.4

7 years ago

0.1.3

7 years ago

0.1.2

7 years ago

0.1.1

7 years ago

0.1.0

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago