0.2.7 • Published 7 years ago

pinch-slider v0.2.7

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

Overview

pinch-slider is a touch slider for which can be zoomed or pinched for vue.js.

Install

$ npm install pinch-slider

Import using module

Import components to your project:

require('pinch-slider/dist/pinch-slider.css');

// in ES6 modules
import { PinchSlider, AlloyFinger, AlloyFingerVue } from 'pinch-slider';

// in CommonJS
const { PinchSlider, AlloyFinger, AlloyFingerVue } = require('pinch-slider');

// in Global variable
const { PinchSlider, AlloyFinger, AlloyFingerVue } = PinchSlider;

And register components:

Vue.use( AlloyFingerVue, { AlloyFinger: AlloyFinger }); // use AlloyFinger's plugin
Vue.component('pinch-slider', PinchSlider);

Import using script tag

<link rel="stylesheet" href="../node-modules/pinch-slider/dist/pinch-slider.css" charset="utf-8">
<script src="../node-modules/pinch-slider/dist/pinch-slider.js"></script>
const { PinchSlider, AlloyFinger, AlloyFingerVue } = PinchSlider;
Vue.use( AlloyFingerVue, { AlloyFinger: AlloyFinger }); // use AlloyFinger's plugin

Vue.component('pinchSlider', PinchSlider);
new Vue({
    el: '.vue-wrapper',
    data: {
        imgs: [
            { src: 'https://cdn.pixabay.com/photo/2016/11/07/05/13/map-1804891__480.jpg' },
            { src: 'https://cdn.pixabay.com/photo/2016/12/09/08/09/texture-1893788__480.jpg' },
            {src:'https://cdn.pixabay.com/photo/2016/10/20/18/35/sunrise-1756274__480.jpg'}
        ],
        currentIndex: 0,
        isFull:false
    },
    methods:{
      showFull() {
        this.isFull = true;
      },
      changePageNo(data) {
            this.currentIndex = data.index;
        }
    }
});

Usage

Work on a Vue instance:

<div class="slider-container">
      <pinch-slider :slides="imgs" :enable-pinch="false" :current-index='currentIndex' @on-slide-change="changePageNo" @on-img-click="showFull">
      </pinch-slider>
</div>
.slider-container {
        width: 100%;
        height: 500px;
        overflow: hidden;
    }

Options

Here list Props and events on the component

OptionDescription
slidesArray(default: []) image lists to be loaded.
enablePinchBoolean(default: true).
currentIndexNumber (default:0) - current image showing
srcKeyString (default:'src') - key for the slider object which contains the image.
lazyLoadBoolean (default:false) - if true, the images won't be downloaded until swiped near to them.
loadingImgUrlString (default:'') - if lazyLoad, the loading image shown before the real image downloaded.
@on-slide-changefunction - trigged when the slider changes, passes current index for the callback
@on-img-clickfunction - trigged when image be clicked, this event cancels bubble

Develop

$ npm run build

Many thanks to

AlloyFinger

License

MIT

0.2.7

7 years ago

0.2.6

7 years ago

0.2.5

7 years ago

0.2.4

7 years ago

0.2.3

7 years ago

0.2.2

7 years ago

0.2.1

7 years ago

0.1.17

7 years ago

0.1.16

7 years ago

0.1.15

7 years ago

0.1.14

7 years ago

0.1.13

7 years ago

0.1.12

7 years ago

0.1.11

7 years ago

0.1.10

7 years ago

0.1.9

7 years ago

0.1.8

7 years ago

0.1.7

7 years ago

0.1.6

7 years ago

0.1.5

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