Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React, {
useEffect,
useReducer,
useRef,
useState
} from 'react';
import type { MouseEvent, TouchEvent } from 'react';

Expand Down Expand Up @@ -85,7 +86,7 @@ function Split({
const children = flattenChildren(reactChildren)

const [state, dispatch] = useReducer(reducer, initialState);

const [style, setStyle] = useState({})
const containerRef = useRef<HTMLDivElement>(null)
const childRefs = useRef<HTMLElement[]>([]);
const gutterRefs = useRef<HTMLElement[]>([]);
Expand All @@ -108,6 +109,7 @@ function Split({
});

const pair = state.pairs[gutterIdx];
setStyle({userSelect: 'none'})
onResizeStarted?.(pair.idx)

// Disable selection.
Expand Down Expand Up @@ -152,6 +154,7 @@ function Split({

if (state.draggingIdx === undefined) throw new Error(`Could not reset cursor and user-select because 'state.draggingIdx' is undefined`);
const pair = state.pairs[state.draggingIdx];
setStyle({})
onResizeFinished?.(pair.idx, allSizes);

// Disable selection.
Expand Down Expand Up @@ -395,6 +398,7 @@ function Split({
<div
className={'__dbk__container ' + `${direction}`}
ref={containerRef}
style={style}
>
{state.isReady && children.map((c, idx) => (
<React.Fragment key={idx}>
Expand Down