From 6caf8267c5b1c66f8909430ad15a8135eb48b16f Mon Sep 17 00:00:00 2001 From: Aria Minaei Date: Tue, 3 May 2022 12:42:53 +0200 Subject: [PATCH] Bugfix: Ensure the focus range doesn't invert upon snapping --- .../FocusRangeZone/FocusRangeThumb.tsx | 36 +++++++++---------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/theatre/studio/src/panels/SequenceEditorPanel/RightOverlay/FocusRangeZone/FocusRangeThumb.tsx b/theatre/studio/src/panels/SequenceEditorPanel/RightOverlay/FocusRangeZone/FocusRangeThumb.tsx index 2fec23e..2f0fe3c 100644 --- a/theatre/studio/src/panels/SequenceEditorPanel/RightOverlay/FocusRangeZone/FocusRangeThumb.tsx +++ b/theatre/studio/src/panels/SequenceEditorPanel/RightOverlay/FocusRangeZone/FocusRangeThumb.tsx @@ -204,6 +204,24 @@ const FocusRangeThumb: React.FC<{ let newPosition: number const oldPosPlusDeltaPos = posBeforeDrag + deltaPos + // Enable snapping + const snapTarget = event + .composedPath() + .find( + (el): el is Element => + el instanceof Element && + el !== hitZoneNode && + el.hasAttribute('data-pos'), + ) + + if (snapTarget) { + const snapPos = parseFloat(snapTarget.getAttribute('data-pos')!) + + if (isFinite(snapPos)) { + newPosition = snapPos + } + } + // Make sure that the focus range has a minimal width if (thumbType === 'start') { // Prevent the start thumb from going below 0 @@ -225,24 +243,6 @@ const FocusRangeThumb: React.FC<{ ) } - // Enable snapping - const snapTarget = event - .composedPath() - .find( - (el): el is Element => - el instanceof Element && - el !== hitZoneNode && - el.hasAttribute('data-pos'), - ) - - if (snapTarget) { - const snapPos = parseFloat(snapTarget.getAttribute('data-pos')!) - - if (isFinite(snapPos)) { - newPosition = snapPos - } - } - const newPositionInFrame = sheet .getSequence() .closestGridPosition(newPosition)