Skip to content

Commit

Permalink
Remove unused code
Browse files Browse the repository at this point in the history
  • Loading branch information
Jondyr committed Jul 16, 2024
1 parent 155d5d9 commit d8eef7c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export const StudioResizableLayoutHandle = ({
const { resizeDelta, containerSize } = useStudioResizableLayoutContext(index);
const { onMouseDown, isResizing } = useStudioResizableLayoutMouseMovement(
orientation,
(delta, _) => {
(delta) => {
resizeDelta(index, delta);
},
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@ import type { StudioResizableOrientation } from '../StudioResizableLayoutContain

export const useStudioResizableLayoutMouseMovement = (
orientation: StudioResizableOrientation,
onMousePosChange: (delta: number, position: number) => void,
onMousePosChange: (delta: number) => void,
): {
onMouseDown: (event: React.MouseEvent<HTMLDivElement>) => () => void;
isResizing: boolean;
} => {
const lastMousePosition = useRef<number>(0);
const startMousePosition = useRef<number>(0);
const [isResizing, setIsResizing] = useState(false);

// throttle mouseMove events to avoid calculating new size before last rerender
Expand All @@ -24,9 +23,8 @@ export const useStudioResizableLayoutMouseMovement = (
if (update.current === lastEventUpdate.current) return;
lastEventUpdate.current = update.current;
const mousePos = orientation === 'horizontal' ? event.clientX : event.clientY;
const mouseTotalDelta = mousePos - startMousePosition.current;
const mouseDelta = mousePos - lastMousePosition.current;
onMousePosChange(mouseDelta, mouseTotalDelta);
onMousePosChange(mouseDelta);
lastMousePosition.current = mousePos;
},
[orientation, onMousePosChange],
Expand All @@ -49,7 +47,6 @@ export const useStudioResizableLayoutMouseMovement = (
event.preventDefault();
setIsResizing(true);
lastMousePosition.current = orientation === 'horizontal' ? event.clientX : event.clientY;
startMousePosition.current = lastMousePosition.current;
window.addEventListener('mousemove', mouseMove);
window.addEventListener('mouseup', mouseUp);
},
Expand Down

0 comments on commit d8eef7c

Please sign in to comment.