Skip to content

Commit

Permalink
Fix subtitle container position logic when video is far down page
Browse files Browse the repository at this point in the history
- E.g. in the case of Amazon Prime when scrolling down the page and
  then opening a video.
  • Loading branch information
killergerbah committed Jul 21, 2024
1 parent 3cf4b58 commit c83dacb
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions extension/src/services/element-overlay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ export class CachingElementOverlay implements ElementOverlay {
const clampedY = Math.max(rect.top + window.scrollY, 0);

if (this.offsetAnchor === OffsetAnchor.bottom) {
const clampedHeight = Math.min(clampedY + rect.height, window.innerHeight);
const clampedHeight = Math.min(clampedY + rect.height, window.innerHeight + window.scrollY);
container.style.top = clampedHeight - this.contentPositionOffset + 'px';
container.style.bottom = '';
} else {
Expand Down Expand Up @@ -510,7 +510,7 @@ export class DefaultElementOverlay implements ElementOverlay {
const clampedY = Math.max(rect.top + window.scrollY, 0);

if (this.offsetAnchor === OffsetAnchor.bottom) {
const clampedHeight = Math.min(clampedY + rect.height, window.innerHeight);
const clampedHeight = Math.min(clampedY + rect.height, window.innerHeight + window.scrollY);
container.style.top = clampedHeight - this.contentPositionOffset + 'px';
container.style.bottom = '';
} else {
Expand Down

0 comments on commit c83dacb

Please sign in to comment.