|
|
@ -2,6 +2,7 @@ import { defineComponent, PropType, reactive } from 'vue';
|
|
|
|
import classNames from '../_util/classNames';
|
|
|
|
import classNames from '../_util/classNames';
|
|
|
|
import createRef from '../_util/createRef';
|
|
|
|
import createRef from '../_util/createRef';
|
|
|
|
import raf from '../_util/raf';
|
|
|
|
import raf from '../_util/raf';
|
|
|
|
|
|
|
|
import supportsPassive from '../_util/supportsPassive';
|
|
|
|
import PropTypes from '../_util/vue-types';
|
|
|
|
import PropTypes from '../_util/vue-types';
|
|
|
|
|
|
|
|
|
|
|
|
const MIN_SIZE = 20;
|
|
|
|
const MIN_SIZE = 20;
|
|
|
@ -60,8 +61,16 @@ export default defineComponent({
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
mounted() {
|
|
|
|
mounted() {
|
|
|
|
this.scrollbarRef.current.addEventListener('touchstart', this.onScrollbarTouchStart);
|
|
|
|
this.scrollbarRef.current.addEventListener(
|
|
|
|
this.thumbRef.current.addEventListener('touchstart', this.onMouseDown);
|
|
|
|
'touchstart',
|
|
|
|
|
|
|
|
this.onScrollbarTouchStart,
|
|
|
|
|
|
|
|
supportsPassive ? ({ passive: true } as EventListenerOptions) : false,
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
this.thumbRef.current.addEventListener(
|
|
|
|
|
|
|
|
'touchstart',
|
|
|
|
|
|
|
|
this.onMouseDown,
|
|
|
|
|
|
|
|
supportsPassive ? ({ passive: true } as EventListenerOptions) : false,
|
|
|
|
|
|
|
|
);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
beforeUnmount() {
|
|
|
|
beforeUnmount() {
|
|
|
@ -92,7 +101,11 @@ export default defineComponent({
|
|
|
|
window.addEventListener('mousemove', this.onMouseMove);
|
|
|
|
window.addEventListener('mousemove', this.onMouseMove);
|
|
|
|
window.addEventListener('mouseup', this.onMouseUp);
|
|
|
|
window.addEventListener('mouseup', this.onMouseUp);
|
|
|
|
|
|
|
|
|
|
|
|
this.thumbRef.current.addEventListener('touchmove', this.onMouseMove);
|
|
|
|
this.thumbRef.current.addEventListener(
|
|
|
|
|
|
|
|
'touchmove',
|
|
|
|
|
|
|
|
this.onMouseMove,
|
|
|
|
|
|
|
|
supportsPassive ? ({ passive: true } as EventListenerOptions) : false,
|
|
|
|
|
|
|
|
);
|
|
|
|
this.thumbRef.current.addEventListener('touchend', this.onMouseUp);
|
|
|
|
this.thumbRef.current.addEventListener('touchend', this.onMouseUp);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
@ -100,9 +113,21 @@ export default defineComponent({
|
|
|
|
window.removeEventListener('mousemove', this.onMouseMove);
|
|
|
|
window.removeEventListener('mousemove', this.onMouseMove);
|
|
|
|
window.removeEventListener('mouseup', this.onMouseUp);
|
|
|
|
window.removeEventListener('mouseup', this.onMouseUp);
|
|
|
|
|
|
|
|
|
|
|
|
this.scrollbarRef.current.removeEventListener('touchstart', this.onScrollbarTouchStart);
|
|
|
|
this.scrollbarRef.current.removeEventListener(
|
|
|
|
this.thumbRef.current.removeEventListener('touchstart', this.onMouseDown);
|
|
|
|
'touchstart',
|
|
|
|
this.thumbRef.current.removeEventListener('touchmove', this.onMouseMove);
|
|
|
|
this.onScrollbarTouchStart,
|
|
|
|
|
|
|
|
supportsPassive ? ({ passive: true } as EventListenerOptions) : false,
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
this.thumbRef.current.removeEventListener(
|
|
|
|
|
|
|
|
'touchstart',
|
|
|
|
|
|
|
|
this.onMouseDown,
|
|
|
|
|
|
|
|
supportsPassive ? ({ passive: true } as EventListenerOptions) : false,
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
this.thumbRef.current.removeEventListener(
|
|
|
|
|
|
|
|
'touchmove',
|
|
|
|
|
|
|
|
this.onMouseMove,
|
|
|
|
|
|
|
|
supportsPassive ? ({ passive: true } as EventListenerOptions) : false,
|
|
|
|
|
|
|
|
);
|
|
|
|
this.thumbRef.current.removeEventListener('touchend', this.onMouseUp);
|
|
|
|
this.thumbRef.current.removeEventListener('touchend', this.onMouseUp);
|
|
|
|
|
|
|
|
|
|
|
|
raf.cancel(this.moveRaf);
|
|
|
|
raf.cancel(this.moveRaf);
|
|
|
|