Skip to content
This repository has been archived by the owner on Oct 1, 2022. It is now read-only.

Commit

Permalink
fix(modal): fix scrollbar compensation in some scaling situations
Browse files Browse the repository at this point in the history
Adding uncertainty, because the scaling can make the gap just slightly smaller than a scrollbar size.

Closes ng-bootstrap#3448
  • Loading branch information
ymeine committed Dec 3, 2019
1 parent 80c8504 commit c6493c3
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/util/scrollbar.ts
Expand Up @@ -56,7 +56,9 @@ export class ScrollBar {
*/
private _isPresent(scrollbarWidth: number): boolean {
const rect = this._document.body.getBoundingClientRect();
return window.innerWidth - (rect.left + rect.right) >= scrollbarWidth;
const bodyToViewportGap = window.innerWidth - (rect.left + rect.right);
const uncertainty = 0.1 * scrollbarWidth;
return bodyToViewportGap >= scrollbarWidth - uncertainty;
}

/**
Expand Down

0 comments on commit c6493c3

Please sign in to comment.