diff --git a/src/components/split-pane/SplitPane.tsx b/src/components/split-pane/SplitPane.tsx index b176b211..012b6f3f 100644 --- a/src/components/split-pane/SplitPane.tsx +++ b/src/components/split-pane/SplitPane.tsx @@ -1,7 +1,7 @@ /** @jsxImportSource @emotion/react */ import { css } from '@emotion/react'; import { - MouseEvent as ReactMouseEvent, + PointerEvent as ReactPointerEvent, createContext, CSSProperties, ReactNode, @@ -114,7 +114,7 @@ export function SplitPane(props: SplitPaneProps) { }, [closePane, closed, openPane]); const splitterRef = useRef(null); - const { onMouseDown } = useSplitPaneSize({ + const { onPointerDown } = useSplitPaneSize({ controlledSide, direction, splitterRef, @@ -183,7 +183,7 @@ export function SplitPane(props: SplitPaneProps) { void; - onMouseDown?: (event: ReactMouseEvent) => void; + onPointerDown?: (event: ReactPointerEvent) => void; direction: SplitPaneDirection; isFinalClosed: boolean; splitterRef: RefObject; } function Splitter(props: SplitterProps) { - const { onDoubleClick, onMouseDown, direction, isFinalClosed, splitterRef } = - props; + const { + onDoubleClick, + onPointerDown, + direction, + isFinalClosed, + splitterRef, + } = props; return (
@@ -298,6 +303,7 @@ function getSeparatorStyle(direction: SplitPaneDirection, enabled: boolean) { alignItems: 'center', userSelect: 'none', minWidth: 11, + touchAction: 'none', ':hover': { backgroundColor: 'rgb(223, 223, 223)', }, diff --git a/src/components/split-pane/useSplitPaneSize.tsx b/src/components/split-pane/useSplitPaneSize.tsx index aee95f58..0a8293bb 100644 --- a/src/components/split-pane/useSplitPaneSize.tsx +++ b/src/components/split-pane/useSplitPaneSize.tsx @@ -26,9 +26,9 @@ export function useSplitPaneSize(options: UseSplitPaneSizeOptions) { onResize, } = options; - function mouseDownCallback() { + function downCallback() { let lastSize: [number, SplitPaneType] | null = null; - function onMouseMove(event: MouseEvent) { + function moveCallback(event: PointerEvent) { if (!splitterRef.current) return; const { clientX, clientY } = event; const parentDiv = splitterRef.current.parentElement as HTMLDivElement; @@ -69,20 +69,20 @@ export function useSplitPaneSize(options: UseSplitPaneSizeOptions) { } } - function mouseUpCallback() { - window.removeEventListener('mousemove', onMouseMove); - window.removeEventListener('mouseup', mouseUpCallback); + function upCallback() { + window.removeEventListener('pointermove', moveCallback); + window.removeEventListener('pointerup', upCallback); if (lastSize && onResize) { onResize(`${lastSize[0]}${lastSize[1]}`); } } - window.addEventListener('mousemove', onMouseMove); - window.addEventListener('mouseup', mouseUpCallback); + window.addEventListener('pointermove', moveCallback); + window.addEventListener('pointerup', upCallback); } return { - onMouseDown: mouseDownCallback, + onPointerDown: downCallback, }; }