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

fix: time tooltip truncated #8527

Merged
merged 4 commits into from
Apr 10, 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
13 changes: 11 additions & 2 deletions src/js/control-bar/progress-control/time-tooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,24 @@ class TimeTooltip extends Component {
// of the player. We calculate any gap between the left edge of the player
// and the left edge of the `SeekBar` and add the number of pixels in the
// `SeekBar` before hitting the `seekBarPoint`
const spaceLeftOfPoint = (seekBarRect.left - playerRect.left) + seekBarPointPx;
let spaceLeftOfPoint = (seekBarRect.left - playerRect.left) + seekBarPointPx;

// This is the space right of the `seekBarPoint` available within the bounds
// of the player. We calculate the number of pixels from the `seekBarPoint`
// to the right edge of the `SeekBar` and add to that any gap between the
// right edge of the `SeekBar` and the player.
const spaceRightOfPoint = (seekBarRect.width - seekBarPointPx) +
let spaceRightOfPoint = (seekBarRect.width - seekBarPointPx) +
(playerRect.right - seekBarRect.right);

// spaceRightOfPoint is always NaN for mouse time display
// because the seekbarRect does not have a right property. This causes
// the mouse tool tip to be truncated when it's close to the right edge of the player.
// In such cases, we ignore the `playerRect.right - seekBarRect.right` value when calculating.
// For the sake of consistency, we ignore seekBarRect.left - playerRect.left for the left edge.
if (!spaceRightOfPoint) {
spaceRightOfPoint = seekBarRect.width - seekBarPointPx;
spaceLeftOfPoint = seekBarPointPx;
}
// This is the number of pixels by which the tooltip will need to be pulled
// further to the right to center it over the `seekBarPoint`.
let pullTooltipBy = tooltipRect.width / 2;
Expand Down
Loading