fix draggable element pixel alignment (#10708)

This commit is contained in:
Josh Hawkins
2024-03-27 08:21:38 -05:00
committed by GitHub
parent d945e77443
commit 98a1e6ee22
2 changed files with 6 additions and 6 deletions

View File

@@ -382,12 +382,12 @@ function useDraggableElement({
const timelineRect = timelineRef.current.getBoundingClientRect();
const timelineTopAbsolute = timelineRect.top;
const rect = segmentElement.getBoundingClientRect();
const segmentTop =
rect.top + scrolled - timelineTopAbsolute - segmentHeight / 2;
const segmentTop = rect.top + scrolled - timelineTopAbsolute;
const offset =
((draggableElementTime - alignedSegmentTime) / segmentDuration) *
segmentHeight;
const newElementPosition = segmentTop - offset;
// subtract half the height of the handlebar cross bar (4px) for pixel perfection
const newElementPosition = segmentTop - offset - 2;
updateDraggableElementPosition(
newElementPosition,