0.2.0 • Published 5 years ago

vue-compare-image v0.2.0

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

Vue Compare Image

All Contributors

Simple Vue.js component to compare two images using slider.

img

NOTE: React Version is also available!

Demo

DEMO

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

In the shell:

yarn add vue-compare-image

// or

npm install --save vue-compare-image

In your component file:

import VueCompareImage from 'vue-compare-image';

export default {
  name: 'app',
  components: { VueCompareImage },
};
<template>
  <VueCompareImage leftImage="image1.jpg" rightImage="image2.jpg" />;
</template>

Props

Prop (* required)typedefaultdescription
handleSizenumber (px)40diameter of slider handle (by pixel)
hoverbooleanfalseWhether to slide at hover
leftImage *stringnullleft image's url
leftImageAltstringnullleft image's alt
leftLabelstringnullLeft image text label
rightImage *stringnullright image's url
rightImageAltstringnullright image's alt
rightLabelstringnullRight image text label
sliderLineWidthnumber (px)2line width of slider (by pixel)
sliderPositionPercentagenumber (float)0.5Starting line position (from 0 to 1)

Dependencies

Contributors