Package Exports
- v-ctrl
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (v-ctrl) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
v-ctrl
An Vue abstract component for mouse dragging, i.e. the pattern below:
--down--move--move---move--...---up--|-->Install
npm install --save v-ctrl
# or
yarn add v-ctrlOr just add a script tag in you html:
<script src="https://unpkg.com/v-ctrl"></script>Demo
A simple range slider:
<template>
<div class="wrapper">
<v-ctrl direction="h" :throttle="80" @change="onChange">
<div class="range-slider">
<div class="progress" :style="{ width: percentage }"></div>
<div class="thumb" :style="{ left: percentage }"></div>
</div>
</v-ctrl>
<p>{{value}}</p>
</div>
</template>
<script>
import VCtrl from 'v-ctrl'
export default {
components: {
'v-ctrl': VCtrl
},
data () {
return { value: 20 }
},
computed: {
percentage () {
return `${this.value}%`
}
},
methods: {
onChange (val) {
this.value = Math.round(val * 100)
}
}
}
</script>Attributes
throttle: Number
Throttling time for mousemove.
direction: Enum('v', 'h', 'vh')
h: emit proportion for the horizontal axis, e.g.0.52v: emit proportion for the vertical axis, e.g0.91vh: emit proportion for both axis, e.g.{ x: 0.24, y: 0.87 }
Event
change
change event is emitted while keeping dragging.