File tree Expand file tree Collapse file tree 5 files changed +22
-11
lines changed Expand file tree Collapse file tree 5 files changed +22
-11
lines changed Original file line number Diff line number Diff line change @@ -93,6 +93,7 @@ export default defineComponent({
93
93
| inactive-style | string | no | '' | css (change inactive option style)style |
94
94
| active-class | string | no | '' | css class |
95
95
| inactive-class | string | no | '' | css class |
96
+ | wheel-speed | number | no | 1 | adjust mouse wheel speed with this value.<br >lower wheel speed, slower scroller |
96
97
97
98
### Event
98
99
| Name | Description |
Original file line number Diff line number Diff line change 1
1
<template >
2
2
<h3 >Basic Example</h3 >
3
3
<scroll-picker
4
+ :wheel-speed =" wheelSpeed"
4
5
:options =" options"
5
6
v-model =" selections" />
6
7
<div style =" margin-top : 30px ;" >
7
8
{{ selections }}
8
9
</div >
10
+ <div style =" padding-top : 30px ;" >
11
+ <span style =" font-size : 14px ; padding-right : 10px ;" >Wheel Speed:</span >
12
+ <input v-model =" wheelSpeed" >
13
+ </div >
9
14
<button style =" margin-top : 30px ;" @click =" onClickRandom" >
10
15
Random
11
16
</button >
@@ -64,17 +69,13 @@ interface Option {
64
69
value: string ;
65
70
}
66
71
67
- interface State {
68
- options: Option [][];
69
- selections: (string | null )[];
70
- }
71
-
72
72
export default defineComponent ({
73
73
name: ' Basic' ,
74
74
setup() {
75
- const state = reactive < State > ({
75
+ const state = reactive ({
76
76
options: mockOptions ,
77
- selections: [],
77
+ selections: [] as string [],
78
+ wheelSpeed: 1
78
79
});
79
80
function random(number : number ) {
80
81
return Math .floor (Math .random () * number );
@@ -83,7 +84,6 @@ export default defineComponent({
83
84
return typeof option === " string" ? option : option .value ;
84
85
}
85
86
function onClickRandom() {
86
- state .selections
87
87
state .selections = state .options .map (option => {
88
88
return getValue (option [random (option .length )]);
89
89
})
Original file line number Diff line number Diff line change 1
1
<template >
2
2
<h3 >Custom Example</h3 >
3
3
<scroll-picker
4
+ :wheel-speed =" wheelSpeed"
4
5
style =" background : white ; height : 200px ;"
5
6
:options =" options"
6
7
v-model =" selections"
24
25
<div style =" margin-top : 30px ;" >
25
26
{{ selections }}
26
27
</div >
28
+ <div style =" padding-top : 30px ;" >
29
+ <span style =" font-size : 14px ; padding-right : 10px ;" >Wheel Speed:</span >
30
+ <input v-model =" wheelSpeed" >
31
+ </div >
27
32
<button style =" margin-top : 30px ;" @click =" onClickRandom" >
28
33
Random
29
34
</button >
@@ -83,11 +88,12 @@ export default defineComponent({
83
88
const state = reactive ({
84
89
options: mockOptions ,
85
90
selections: [' a2' ,' b2' ,' c1' ],
91
+ wheelSpeed: 1
86
92
});
87
93
function random(number : number ) {
88
94
return Math .floor (Math .random () * number );
89
95
}
90
- function getValue(option ) {
96
+ function getValue(option : any ) {
91
97
return typeof option === " string" ? option : option .value ;
92
98
}
93
99
function onClickRandom() {
Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " vue3-scroll-picker" ,
3
- "version" : " 0.1.14 " ,
3
+ "version" : " 0.1.15 " ,
4
4
"private" : false ,
5
5
"description" : " Vue 3 scroll picker plugin." ,
6
6
"author" :
" hj <[email protected] >" ,
Original file line number Diff line number Diff line change @@ -131,6 +131,10 @@ export default defineComponent({
131
131
inactiveStyle: {
132
132
default: " " ,
133
133
type: String
134
+ },
135
+ wheelSpeed: {
136
+ default: 1 ,
137
+ type: Number
134
138
}
135
139
},
136
140
emits: [" update:modelValue" ],
@@ -263,7 +267,7 @@ export default defineComponent({
263
267
preventDefault (event );
264
268
const content = getContent (event );
265
269
if (content ) {
266
- content .scrollTop += (event as WheelEvent ).deltaY ;
270
+ content .scrollTop += (event as WheelEvent ).deltaY * props . wheelSpeed ;
267
271
const { columnIndex, rowIndex } = getColumnRowIndex (content );
268
272
const newSelections = getSelections (columnIndex , rowIndex );
269
273
setSelections (newSelections );
You can’t perform that action at this time.
0 commit comments