Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Limit time tooltip display offset to playable range width #629

Merged
merged 1 commit into from
Aug 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -490,15 +490,20 @@ function ProgressBar({

let time = convertToTime(e, offsetx, currentSrcIndex);

if (!time) { return; }

setActiveSrcIndex(currentSrcIndex);
setCurrentTime(time);

// Set text in the tooltip as the time relevant to the pointer event's position
timeToolRef.current.innerHTML = formatTooltipTime(time);

// Calculate the horizontal position of the time tooltip
// using the event's offsetX property
let leftWidth = offsetx - timeToolRef.current.offsetWidth / 2; // deduct 0.5 x width of tooltip element
// Calculate the horizontal position of the time tooltip using the event's offsetX property
// Set time tooltip offset starting from the start of playable range
let leftWidth = leftBlockRef.current?.offsetWidth <= offsetx ? offsetx - leftBlockRef.current?.offsetWidth : offsetx;
// Set time tooltip offset to not excedd the end of playable range
leftWidth = Math.min(leftWidth, sliderRangeRef.current?.offsetWidth + leftBlockRef.current?.offsetWidth);
leftWidth = leftWidth - timeToolRef.current.offsetWidth / 2; // deduct 0.5 x width of tooltip element
if (leftBlockRef.current) leftWidth += leftBlockRef.current.offsetWidth; // add the blocked off area width

// Add the width of preceding dummy ranges
Expand Down