|
174 | 174 | } |
175 | 175 | } |
176 | 176 |
|
177 | | - const handleScroll = (event: MouseEvent): void => { |
| 177 | + const handleScroll = (event: PointerEvent): void => { |
178 | 178 | scrolling = false |
179 | 179 | if ( |
180 | 180 | (divBar == null && isScrolling === 'vertical') || |
|
185 | 185 | } |
186 | 186 | const rectScroll = divScroll.getBoundingClientRect() |
187 | 187 | if (isScrolling === 'vertical') { |
188 | | - let Y = event.clientY - dXY |
| 188 | + let Y = Math.round(event.clientY) - dXY |
189 | 189 | if (Y < rectScroll.top + shiftTop + 2) Y = rectScroll.top + shiftTop + 2 |
190 | 190 | if (Y > rectScroll.bottom - divBar.clientHeight - shiftBottom - 2) { |
191 | 191 | Y = rectScroll.bottom - divBar.clientHeight - shiftBottom - 2 |
|
201 | 201 | divScroll.scrollTop = (divScroll.scrollHeight - divScroll.clientHeight) * procBar |
202 | 202 | } |
203 | 203 | } else if (isScrolling === 'horizontal') { |
204 | | - let X = event.clientX - dXY |
| 204 | + let X = Math.round(event.clientX) - dXY |
205 | 205 | if (X < rectScroll.left + 2 + shiftLeft) X = rectScroll.left + 2 + shiftLeft |
206 | 206 | if (X > rectScroll.right - divBarH.clientWidth - (mask !== 'none' ? 12 : 2) - shiftRight) { |
207 | 207 | X = rectScroll.right - divBarH.clientWidth - (mask !== 'none' ? 12 : 2) - shiftRight |
|
215 | 215 | } |
216 | 216 | } |
217 | 217 | const onScrollEnd = (): void => { |
218 | | - document.removeEventListener('mousemove', handleScroll) |
| 218 | + document.removeEventListener('pointermove', handleScroll) |
219 | 219 | document.body.style.userSelect = 'auto' |
220 | 220 | document.body.style.webkitUserSelect = 'auto' |
221 | | - document.removeEventListener('mouseup', onScrollEnd) |
| 221 | + document.removeEventListener('pointerup', onScrollEnd) |
222 | 222 | isScrolling = false |
223 | 223 | } |
224 | | - const onScrollStart = (event: MouseEvent, direction: 'vertical' | 'horizontal'): void => { |
| 224 | + const onScrollStart = (event: PointerEvent, direction: 'vertical' | 'horizontal'): void => { |
225 | 225 | if (divScroll == null) return |
226 | 226 | scrolling = false |
227 | | - dXY = direction === 'vertical' ? event.offsetY : event.offsetX |
228 | | - document.addEventListener('mouseup', onScrollEnd) |
229 | | - document.addEventListener('mousemove', handleScroll) |
| 227 | + dXY = Math.round(direction === 'vertical' ? event.offsetY : event.offsetX) |
| 228 | + document.addEventListener('pointerup', onScrollEnd) |
| 229 | + document.addEventListener('pointermove', handleScroll) |
230 | 230 | document.body.style.userSelect = 'none' |
231 | 231 | document.body.style.webkitUserSelect = 'none' |
232 | 232 | isScrolling = direction |
|
666 | 666 | class:hovered={isScrolling === 'vertical'} |
667 | 667 | class:reverse={scrollDirection === 'vertical-reverse'} |
668 | 668 | bind:this={divBar} |
669 | | - on:mousedown|stopPropagation={(ev) => { |
| 669 | + on:pointerdown|stopPropagation={(ev) => { |
670 | 670 | onScrollStart(ev, 'vertical') |
671 | 671 | }} |
672 | | - on:mouseleave={checkFade} |
| 672 | + on:pointerleave={checkFade} |
673 | 673 | /> |
674 | 674 | {/if} |
675 | 675 | {#if horizontal && maskH !== 'none'} |
|
687 | 687 | class="bar-horizontal" |
688 | 688 | class:hovered={isScrolling === 'horizontal'} |
689 | 689 | bind:this={divBarH} |
690 | | - on:mousedown|stopPropagation={(ev) => { |
| 690 | + on:pointerdown|stopPropagation={(ev) => { |
691 | 691 | onScrollStart(ev, 'horizontal') |
692 | 692 | }} |
693 | | - on:mouseleave={checkFade} |
| 693 | + on:pointerleave={checkFade} |
694 | 694 | /> |
695 | 695 | {/if} |
696 | 696 | </div> |
|
864 | 864 | overscroll-behavior: none; |
865 | 865 | } |
866 | 866 | &::-webkit-scrollbar:vertical { |
| 867 | + display: none; |
867 | 868 | width: 0; |
868 | 869 | } |
869 | 870 | &::-webkit-scrollbar:horizontal { |
| 871 | + display: none; |
870 | 872 | height: 0; |
871 | 873 | } |
872 | 874 |
|
|
0 commit comments