Skip to content

Commit

Permalink
js: fix subtitles disappear when resizing
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitrylyzo committed May 8, 2022
1 parent 2e07a55 commit a0aa8ef
Showing 1 changed file with 14 additions and 18 deletions.
32 changes: 14 additions & 18 deletions src/subtitles-octopus.js
Original file line number Diff line number Diff line change
Expand Up @@ -742,26 +742,22 @@ var SubtitlesOctopus = function (options) {
return;
}


if (
self.canvas.width != width ||
self.canvas.height != height ||
self.canvas.style.top != top ||
self.canvas.style.left != left
) {
if (videoSize != null) {
self.canvasParent.style.position = 'relative';
self.canvas.style.display = 'block';
self.canvas.style.position = 'absolute';
self.canvas.style.width = videoSize.width + 'px';
self.canvas.style.height = videoSize.height + 'px';
self.canvas.style.top = top + 'px';
self.canvas.style.left = left + 'px';
self.canvas.style.pointerEvents = 'none';
}

if (self.canvas._prevWidth != width || self.canvas._prevHeight != height) {
self.canvas.width = width;
self.canvas.height = height;

if (videoSize != null) {
self.canvasParent.style.position = 'relative';
self.canvas.style.display = 'block';
self.canvas.style.position = 'absolute';
self.canvas.style.width = videoSize.width + 'px';
self.canvas.style.height = videoSize.height + 'px';
self.canvas.style.top = top + 'px';
self.canvas.style.left = left + 'px';
self.canvas.style.pointerEvents = 'none';
}
self.canvas._prevWidth = width;
self.canvas._prevHeight = height;

self.worker.postMessage({
target: 'canvas',
Expand Down

0 comments on commit a0aa8ef

Please sign in to comment.