mirror of
https://github.com/hanzoai/sentinel.git
synced 2026-10-30 14:49:14 +00:00
33 lines
1.0 KiB
TypeScript
33 lines
1.0 KiB
TypeScript
import {useCallback} from 'react';
|
|
import debounce from 'lodash/debounce';
|
|
|
|
import type {SplitPanelProps} from 'sentry/components/splitPanel';
|
|
import SplitPanel from 'sentry/components/splitPanel';
|
|
import useSplitPanelTracking from 'sentry/utils/replays/hooks/useSplitPanelTracking';
|
|
|
|
function ReplaySplitPanel(props: SplitPanelProps) {
|
|
const {availableSize} = props;
|
|
const isLeftRight = 'left' in props;
|
|
|
|
const {setStartPosition, logEndPosition} = useSplitPanelTracking({
|
|
slideDirection: isLeftRight ? 'leftright' : 'updown',
|
|
});
|
|
|
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
const handleResize = useCallback(
|
|
debounce(newSize => logEndPosition(`${(newSize / availableSize) * 100}%`), 750),
|
|
[logEndPosition, availableSize]
|
|
);
|
|
|
|
const handleMouseDown = useCallback(
|
|
(sizePct: `${number}%`) => {
|
|
setStartPosition(sizePct);
|
|
},
|
|
[setStartPosition]
|
|
);
|
|
|
|
return <SplitPanel {...props} onMouseDown={handleMouseDown} onResize={handleResize} />;
|
|
}
|
|
|
|
export default ReplaySplitPanel;
|