Skip to content

Commit

Permalink
fix: add condition for position of textTrackDisplay in STV devices
Browse files Browse the repository at this point in the history
  • Loading branch information
CarlosVillasenor committed Aug 20, 2024
1 parent 3f92d15 commit 870de98
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
1 change: 1 addition & 0 deletions src/css/components/_text-track.scss
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ video::-webkit-media-text-track-display {
}

.video-js .vjs-text-track-display > div {
position: absolute;
top: 0;
right: 0;
bottom: 0;
Expand Down
21 changes: 14 additions & 7 deletions src/js/tracks/text-track-display.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import Component from '../component';
import * as Fn from '../utils/fn.js';
import * as Dom from '../utils/dom.js';
import window from 'global/window';
import * as browser from '../utils/browser';

/** @import Player from '../player' */

Expand Down Expand Up @@ -323,10 +324,22 @@ class TextTrackDisplay extends Component {
if (!window.CSS.supports('inset', '10px')) {
const textTrackDisplay = this.el_;
const vjsTextTrackCues = textTrackDisplay.querySelectorAll('.vjs-text-track-cue');
const controlBarHeight = this.player_.controlBar.el_.getBoundingClientRect().height;
const playerHeight = this.player_.el_.getBoundingClientRect().height;

// Clear inline style before getting actual height of textTrackDisplay
textTrackDisplay.style = '';
const textTrackDisplayHeight = textTrackDisplay.getBoundingClientRect().height;

// textrack style updates, this styles are required to be inline
tryUpdateStyle(textTrackDisplay, 'position', 'relative');
tryUpdateStyle(textTrackDisplay, 'height', (playerHeight - controlBarHeight) + 'px');
tryUpdateStyle(textTrackDisplay, 'top', 'unset');

if (browser.IS_SMART_TV) {
tryUpdateStyle(textTrackDisplay, 'bottom', playerHeight + 'px');
} else {
tryUpdateStyle(textTrackDisplay, 'bottom', '0px');

Check warning on line 341 in src/js/tracks/text-track-display.js

View check run for this annotation

Codecov / codecov/patch

src/js/tracks/text-track-display.js#L341

Added line #L341 was not covered by tests
}

// vjsTextTrackCue style updates
if (vjsTextTrackCues.length > 0) {
Expand All @@ -342,12 +355,6 @@ class TextTrackDisplay extends Component {
}
});
}

// textrack style updates, this styles are required to be inline
tryUpdateStyle(textTrackDisplay, 'position', 'relative');
tryUpdateStyle(textTrackDisplay, 'height', textTrackDisplayHeight + 'px');
tryUpdateStyle(textTrackDisplay, 'top', 'unset');
tryUpdateStyle(textTrackDisplay, 'bottom', '0px');
}
}

Expand Down

0 comments on commit 870de98

Please sign in to comment.