Skip to content

Commit 33ac636

Browse files
committed
release
1 parent f3c8d0a commit 33ac636

File tree

10 files changed

+1123
-1
lines changed

10 files changed

+1123
-1
lines changed

.editorconfig

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
root = true
2+
3+
[*]
4+
indent_style = space
5+
indent_size = 2
6+
end_of_line = lf
7+
charset = utf-8
8+
trim_trailing_whitespace = false
9+
insert_final_newline = false

README.md

Lines changed: 85 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,86 @@
11
# v-ctrl
2-
v-ctrl
2+
3+
An Vue abstract component for mouse dragging, i.e. the pattern below:
4+
5+
```
6+
--down--move--move---move--...---up--|-->
7+
```
8+
9+
## Install
10+
11+
```bash
12+
npm install --save v-ctrl
13+
14+
# or
15+
yarn add v-ctrl
16+
```
17+
18+
Or just add a `script` tag in you html:
19+
20+
```html
21+
<script src="https://unpkg.com/v-ctrl"></script>
22+
```
23+
24+
## Demo
25+
26+
A simple range slider:
27+
28+
```html
29+
<template>
30+
<div class="wrapper">
31+
<v-ctrl direction="h" :throttle="80" @change="onChange">
32+
<div class="range-slider">
33+
<div class="progress" :style="{ width: percentage }"></div>
34+
<div class="thumb" :style="{ left: percentage }"></div>
35+
</div>
36+
</v-ctrl>
37+
<p>{{value}}</p>
38+
</div>
39+
</template>
40+
41+
<script>
42+
import VCtrl from 'v-ctrl'
43+
44+
export default {
45+
components: {
46+
'v-ctrl': VCtrl
47+
},
48+
49+
data () {
50+
return { value: 20 }
51+
},
52+
53+
computed: {
54+
percentage () {
55+
return `${this.value}%`
56+
}
57+
},
58+
59+
methods: {
60+
onChange (val) {
61+
this.value = Math.round(val * 100)
62+
}
63+
}
64+
}
65+
</script>
66+
```
67+
68+
[Live demo](https://v-comp.github.io/v-ctrl/)
69+
70+
## Attributes
71+
72+
### `throttle`: `Number`
73+
74+
Throttling time for mousemove.
75+
76+
### `direction`: `Enum('v', 'h', 'vh')`
77+
78+
* `h`: emit proportion for the horizontal axis, e.g. `0.52`
79+
* `v`: emit proportion for the vertical axis, e.g `0.91`
80+
* `vh`: emit proportion for both axis, e.g. `{ x: 0.24, y: 0.87 }`
81+
82+
## Event
83+
84+
### `change`
85+
86+
`change` event is emitted while keeping dragging.

dist/index.esm.js

Lines changed: 103 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.esm.js.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)