Skip to content

Commit eb83157

Browse files
authored
fix(UI): Fix erroneous current time when dragging (#8558)
Fixes #8557
1 parent 91034c4 commit eb83157

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

ui/seek_bar.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,11 +198,11 @@ shaka.ui.SeekBar = class extends shaka.ui.RangeElement {
198198
const min = parseFloat(this.bar.min);
199199
const max = parseFloat(this.bar.max);
200200
// Pixels from the left of the range element
201-
const mousePosition = event.clientX - rect.left;
201+
const mousePosition = Math.max(0, event.clientX - rect.left);
202202
// Pixels per unit value of the range element.
203203
const scale = (max - min) / rect.width;
204204
// Mouse position in units, which may be outside the allowed range.
205-
const value = Math.round(min + scale * mousePosition);
205+
const value = Math.min(max, Math.round(min + scale * mousePosition));
206206
if (!this.player.getImageTracks().length) {
207207
this.hideThumbnail_();
208208
this.showTime_(mousePosition, value);

0 commit comments

Comments
 (0)