1.0.5 • Published 3 years ago

vue-header-compare v1.0.5

Weekly downloads
-
License
MIT
Repository
-
Last release
3 years ago

Vue Image Compare

Requirements

Installation

npm i vue-image-compare --save

Usage

import Vue from 'vue';
import VueImageCompare from 'vue-image-compare';

Vue.use(VueImageCompare);

new Vue({
  data() {
    return {
      before: '/img/before.jpg',
      after: '/img/after.jpg'
    }
  }
}).$mount('#app');
<div id="app">
  <image-compare :before="before" :after="after"/>
</div>

If you are not using using es6, instead of importing add

<script src="/path/to/vue-image-compare.js"></script>

just before closing body tag.

Props

NameTypeDescriptionRequiredDefault
beforeStringPath to the image image before changeYesundefined
afterStringPath to the image image after changeYesundefined
fullBooleanDetermines if images are stretched to fill parent element. Can be used with help of CSS object-fit: cover to create full page image comparisonNofalse
paddingObjectSet left and right "padding" in pixels, so handle can not reach edge of an imageNo{ left: 0, right: 0 }
hideAfterBooleanHide image after and handleNofalse

Slots

  • icon-left - element to be placed on the left side of the handle
  • icon-right - element to be placed on the right side of the handle

Example:

<image-compare before="/img/before.jpg" after="/img/after.jpg" :padding="{ left: 50, right: 50 }">
  <i class="fa fa-angle-left" aria-hidden="true" slot="icon-left"></i>
  <i class="fa fa-angle-right" aria-hidden="true" slot="icon-right"></i>
</image-compare>

License

MIT

1.0.2

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago