Skip to content

Commit

Permalink
fix: Force update captions when element resizes (shaka-project#3426)
Browse files Browse the repository at this point in the history
  • Loading branch information
Álvaro Velad Galván authored May 26, 2021
1 parent 0579ee7 commit a09fa31
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions lib/text/ui_text_displayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,15 @@ shaka.text.UITextDisplayer = class {
this.eventManager_.listen(document, 'fullscreenchange', () => {
this.updateCaptions_(/* forceUpdate= */ true);
});

/** @private {ResizeObserver} */
this.resizeObserver_ = null;
if ('ResizeObserver' in window) {
this.resizeObserver_ = new ResizeObserver(() => {
this.updateCaptions_(/* forceUpdate= */ true);
});
this.resizeObserver_.observe(this.textContainer_);
}
}


Expand Down Expand Up @@ -132,6 +141,11 @@ shaka.text.UITextDisplayer = class {
this.eventManager_.release();
this.eventManager_ = null;
}

if (this.resizeObserver_) {
this.resizeObserver_.disconnect();
this.resizeObserver_ = null;
}
}


Expand Down

0 comments on commit a09fa31

Please sign in to comment.