@@ -2,6 +2,7 @@ import { defineComponent, PropType, reactive } from 'vue';
22import classNames from '../_util/classNames' ;
33import createRef from '../_util/createRef' ;
44import raf from '../_util/raf' ;
5+ import supportsPassive from '../_util/supportsPassive' ;
56import PropTypes from '../_util/vue-types' ;
67
78const MIN_SIZE = 20 ;
@@ -60,8 +61,16 @@ export default defineComponent({
6061 } ,
6162
6263 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+ ) ;
6574 } ,
6675
6776 beforeUnmount ( ) {
@@ -92,17 +101,33 @@ export default defineComponent({
92101 window . addEventListener ( 'mousemove' , this . onMouseMove ) ;
93102 window . addEventListener ( 'mouseup' , this . onMouseUp ) ;
94103
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+ ) ;
96109 this . thumbRef . current . addEventListener ( 'touchend' , this . onMouseUp ) ;
97110 } ,
98111
99112 removeEvents ( ) {
100113 window . removeEventListener ( 'mousemove' , this . onMouseMove ) ;
101114 window . removeEventListener ( 'mouseup' , this . onMouseUp ) ;
102115
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+ ) ;
106131 this . thumbRef . current . removeEventListener ( 'touchend' , this . onMouseUp ) ;
107132
108133 raf . cancel ( this . moveRaf ) ;
0 commit comments