mirror of
https://github.com/blakeblackshear/frigate.git
synced 2024-11-21 19:07:46 +01:00
better timeline scrolling behavior when dragging (#10269)
This commit is contained in:
parent
ac9cd72f28
commit
b5edcd2fae
@ -71,6 +71,7 @@ function useDraggableHandler({
|
|||||||
(
|
(
|
||||||
newHandlePosition: number,
|
newHandlePosition: number,
|
||||||
segmentStartTime: number,
|
segmentStartTime: number,
|
||||||
|
scrollTimeline: boolean,
|
||||||
updateHandle: boolean,
|
updateHandle: boolean,
|
||||||
) => {
|
) => {
|
||||||
const thumb = scrollTimeRef.current;
|
const thumb = scrollTimeRef.current;
|
||||||
@ -85,10 +86,12 @@ function useDraggableHandler({
|
|||||||
minute: "2-digit",
|
minute: "2-digit",
|
||||||
...(segmentDuration < 60 && { second: "2-digit" }),
|
...(segmentDuration < 60 && { second: "2-digit" }),
|
||||||
});
|
});
|
||||||
scrollIntoView(thumb, {
|
if (scrollTimeline) {
|
||||||
scrollMode: "if-needed",
|
scrollIntoView(thumb, {
|
||||||
behavior: "smooth",
|
block: "center",
|
||||||
});
|
behavior: "smooth",
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -136,7 +139,7 @@ function useDraggableHandler({
|
|||||||
const parentScrollTop = getCumulativeScrollTop(timelineRef.current);
|
const parentScrollTop = getCumulativeScrollTop(timelineRef.current);
|
||||||
|
|
||||||
const newHandlePosition = Math.min(
|
const newHandlePosition = Math.min(
|
||||||
visibleTimelineHeight - timelineTop + parentScrollTop,
|
visibleTimelineHeight + parentScrollTop,
|
||||||
Math.max(
|
Math.max(
|
||||||
segmentHeight + scrolled,
|
segmentHeight + scrolled,
|
||||||
clientY - timelineTop + parentScrollTop,
|
clientY - timelineTop + parentScrollTop,
|
||||||
@ -148,9 +151,14 @@ function useDraggableHandler({
|
|||||||
timelineStart - segmentIndex * segmentDuration,
|
timelineStart - segmentIndex * segmentDuration,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const scrollTimeline =
|
||||||
|
clientY < visibleTimelineHeight * 0.1 ||
|
||||||
|
clientY > visibleTimelineHeight * 0.9;
|
||||||
|
|
||||||
updateHandlebarPosition(
|
updateHandlebarPosition(
|
||||||
newHandlePosition - segmentHeight,
|
newHandlePosition - segmentHeight,
|
||||||
segmentStartTime,
|
segmentStartTime,
|
||||||
|
scrollTimeline,
|
||||||
false,
|
false,
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -202,6 +210,7 @@ function useDraggableHandler({
|
|||||||
newHandlePosition - segmentHeight,
|
newHandlePosition - segmentHeight,
|
||||||
handlebarTime,
|
handlebarTime,
|
||||||
true,
|
true,
|
||||||
|
true,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
// we know that these deps are correct
|
// we know that these deps are correct
|
||||||
|
Loading…
Reference in New Issue
Block a user