| | |
| | | window.removeEventListener('touchend', end); |
| | | window.removeEventListener('mouseup', end); |
| | | |
| | | window.addEventListener('touchmove', move); |
| | | // passive: false 以便拖动滑块时阻止页面滚动 |
| | | window.addEventListener('touchmove', move, { passive: false }); |
| | | window.addEventListener('mousemove', move); |
| | | |
| | | // 鼠标松开 |
| | |
| | | // 鼠标移动 |
| | | function move(e: MouseEvent | TouchEvent) { |
| | | if (status.value && isEnd.value === false) { |
| | | // 移动端拖动时阻止页面跟随滚动 |
| | | if (e.cancelable) e.preventDefault(); |
| | | const x = |
| | | ((e as TouchEvent).touches |
| | | ? (e as TouchEvent).touches[0]?.pageX |