Skip to content

Commit

Permalink
Clamp subtitle container width by window width
Browse files Browse the repository at this point in the history
  • Loading branch information
killergerbah committed Aug 11, 2024
1 parent a14bb14 commit a454804
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions extension/src/services/element-overlay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,8 @@ export class CachingElementOverlay implements ElementOverlay {
container.style.width = '';
} else {
container.style.maxWidth = '';
container.style.width = (rect.width * this.contentWidthPercentage) / 100 + 'px';
container.style.width =
Math.min(window.innerWidth, (rect.width * this.contentWidthPercentage) / 100) + 'px';
}

const clampedY = Math.max(rect.top + window.scrollY, 0);
Expand Down Expand Up @@ -515,7 +516,8 @@ export class DefaultElementOverlay implements ElementOverlay {
container.style.width = '';
} else {
container.style.maxWidth = '';
container.style.width = (rect.width * this.contentWidthPercentage) / 100 + 'px';
container.style.width =
Math.min(window.innerWidth, (rect.width * this.contentWidthPercentage) / 100) + 'px';
}

const clampedY = Math.max(rect.top + window.scrollY, 0);
Expand Down

0 comments on commit a454804

Please sign in to comment.