Limit slider bubble position to its track

This commit is contained in:
Dmitry Lyzo 2020-02-13 11:50:22 +03:00
parent c4824abfb0
commit e13e6f38d5
2 changed files with 7 additions and 2 deletions

View File

@ -227,7 +227,7 @@
position: absolute;
top: 0;
left: 0;
transform: translate3d(-48%, -120%, 0);
transform: translate3d(-50%, -120%, 0);
background: #282828;
color: #fff;
display: flex;

View File

@ -48,8 +48,13 @@ define(['browser', 'dom', 'layoutManager', 'keyboardnavigation', 'css!./emby-sli
function updateBubble(range, value, bubble, bubbleText) {
requestAnimationFrame(function () {
var bubbleTrackRect = range.sliderBubbleTrack.getBoundingClientRect();
var bubbleRect = bubble.getBoundingClientRect();
bubble.style.left = value + '%';
var bubblePos = bubbleTrackRect.width * value / 100;
bubblePos = Math.min(Math.max(bubblePos, bubbleRect.width / 2), bubbleTrackRect.width - bubbleRect.width / 2);
bubble.style.left = bubblePos + 'px';
if (range.getBubbleHtml) {
value = range.getBubbleHtml(value);