Fix thumbnail scrubber crash (#4063)

* Fix scrubber crash when cursor on right-most pixel
* Minimise debounce for smoother scrubbing
This commit is contained in:
WithoutPants
2023-08-27 10:13:48 +10:00
committed by GitHub
parent 371a74d445
commit 8abb3c0d08

View File

@@ -20,7 +20,7 @@ const HoverScrubber: React.FC<IHoverScrubber> = ({
const { width } = e.currentTarget.getBoundingClientRect(); const { width } = e.currentTarget.getBoundingClientRect();
const x = e.nativeEvent.offsetX; const x = e.nativeEvent.offsetX;
return Math.floor((x / width) * totalSprites); return Math.floor((x / width) * (totalSprites - 1));
} }
function onMouseMove(e: React.MouseEvent<HTMLDivElement, MouseEvent>) { function onMouseMove(e: React.MouseEvent<HTMLDivElement, MouseEvent>) {
@@ -104,7 +104,7 @@ export const PreviewScrubber: React.FC<IScenePreviewProps> = ({
const debounceSetActiveIndex = useDebounce( const debounceSetActiveIndex = useDebounce(
setActiveIndex, setActiveIndex,
[setActiveIndex], [setActiveIndex],
10 1
); );
const spriteInfo = useSpriteInfo(vttPath); const spriteInfo = useSpriteInfo(vttPath);