Bugfix: Ensure the focus range doesn't invert upon snapping
This commit is contained in:
parent
3ecc3dd012
commit
6caf8267c5
1 changed files with 18 additions and 18 deletions
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue