@@ -2,6 +2,7 @@ import { defineComponent, PropType, reactive } from 'vue';
2
2
import classNames from '../_util/classNames' ;
3
3
import createRef from '../_util/createRef' ;
4
4
import raf from '../_util/raf' ;
5
+ import supportsPassive from '../_util/supportsPassive' ;
5
6
import PropTypes from '../_util/vue-types' ;
6
7
7
8
const MIN_SIZE = 20 ;
@@ -60,8 +61,16 @@ export default defineComponent({
60
61
} ,
61
62
62
63
mounted ( ) {
63
- this . scrollbarRef . current . addEventListener ( 'touchstart' , this . onScrollbarTouchStart ) ;
64
- this . thumbRef . current . addEventListener ( 'touchstart' , this . onMouseDown ) ;
64
+ this . scrollbarRef . current . addEventListener (
65
+ 'touchstart' ,
66
+ this . onScrollbarTouchStart ,
67
+ supportsPassive ? ( { passive : true } as EventListenerOptions ) : false ,
68
+ ) ;
69
+ this . thumbRef . current . addEventListener (
70
+ 'touchstart' ,
71
+ this . onMouseDown ,
72
+ supportsPassive ? ( { passive : true } as EventListenerOptions ) : false ,
73
+ ) ;
65
74
} ,
66
75
67
76
beforeUnmount ( ) {
@@ -92,17 +101,33 @@ export default defineComponent({
92
101
window . addEventListener ( 'mousemove' , this . onMouseMove ) ;
93
102
window . addEventListener ( 'mouseup' , this . onMouseUp ) ;
94
103
95
- this . thumbRef . current . addEventListener ( 'touchmove' , this . onMouseMove ) ;
104
+ this . thumbRef . current . addEventListener (
105
+ 'touchmove' ,
106
+ this . onMouseMove ,
107
+ supportsPassive ? ( { passive : true } as EventListenerOptions ) : false ,
108
+ ) ;
96
109
this . thumbRef . current . addEventListener ( 'touchend' , this . onMouseUp ) ;
97
110
} ,
98
111
99
112
removeEvents ( ) {
100
113
window . removeEventListener ( 'mousemove' , this . onMouseMove ) ;
101
114
window . removeEventListener ( 'mouseup' , this . onMouseUp ) ;
102
115
103
- this . scrollbarRef . current . removeEventListener ( 'touchstart' , this . onScrollbarTouchStart ) ;
104
- this . thumbRef . current . removeEventListener ( 'touchstart' , this . onMouseDown ) ;
105
- this . thumbRef . current . removeEventListener ( 'touchmove' , this . onMouseMove ) ;
116
+ this . scrollbarRef . current . removeEventListener (
117
+ 'touchstart' ,
118
+ this . onScrollbarTouchStart ,
119
+ supportsPassive ? ( { passive : true } as EventListenerOptions ) : false ,
120
+ ) ;
121
+ this . thumbRef . current . removeEventListener (
122
+ 'touchstart' ,
123
+ this . onMouseDown ,
124
+ supportsPassive ? ( { passive : true } as EventListenerOptions ) : false ,
125
+ ) ;
126
+ this . thumbRef . current . removeEventListener (
127
+ 'touchmove' ,
128
+ this . onMouseMove ,
129
+ supportsPassive ? ( { passive : true } as EventListenerOptions ) : false ,
130
+ ) ;
106
131
this . thumbRef . current . removeEventListener ( 'touchend' , this . onMouseUp ) ;
107
132
108
133
raf . cancel ( this . moveRaf ) ;
0 commit comments