File tree Expand file tree Collapse file tree 1 file changed +32
-0
lines changed
src/js/control-bar/progress-control Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -53,6 +53,38 @@ class TimeTooltip extends Component {
53
53
*/
54
54
update ( seekBarRect , seekBarPoint , content ) {
55
55
this . write ( content ) ;
56
+
57
+ const seekBarRectWidth = seekBarRect . width ;
58
+ const position = seekBarRectWidth * seekBarPoint ;
59
+ const timeTooltipWidth = parseFloat ( Dom . computedStyle ( this . el ( ) , 'width' ) ) ;
60
+ const timeTooltipPosition = position + timeTooltipWidth / 2 ;
61
+ const isSeekBarSmallerThanTimeTooltip = seekBarRectWidth < timeTooltipWidth ;
62
+
63
+ // Keeps the component centered if were not reaching the far left/right
64
+ // of the seek bar or if the seek bar is smaller than the time tooltip
65
+ if (
66
+ timeTooltipPosition >= timeTooltipWidth &&
67
+ timeTooltipPosition <= seekBarRectWidth &&
68
+ this . el ( ) . style . length ||
69
+ isSeekBarSmallerThanTimeTooltip
70
+ ) {
71
+ this . el ( ) . style = '' ;
72
+ return ;
73
+ }
74
+
75
+ // Avoid component right overflow
76
+ const isOverflowingRight = timeTooltipPosition >= seekBarRectWidth ;
77
+
78
+ if ( isOverflowingRight ) {
79
+ this . el ( ) . style . transform = `translateX(calc(50% - ${ Math . abs ( seekBarRectWidth - timeTooltipPosition ) } px))` ;
80
+ }
81
+
82
+ // Avoid component left overflow
83
+ const isOverflowingLeft = timeTooltipPosition <= timeTooltipWidth ;
84
+
85
+ if ( isOverflowingLeft ) {
86
+ this . el ( ) . style . transform = `translateX(calc(50% + ${ Math . abs ( timeTooltipPosition - timeTooltipWidth ) } px))` ;
87
+ }
56
88
}
57
89
58
90
/**
You can’t perform that action at this time.
0 commit comments