Skip to content

Commit

Permalink
noissue: add dev time check for overflow:hidden on body
Browse files Browse the repository at this point in the history
  • Loading branch information
theKashey committed Jun 6, 2022
1 parent f8b9a22 commit 3a6aafd
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,15 @@ const parse = (x: string | null) => parseInt(x || '', 10) || 0;

const getOffset = (gapMode: GapMode): number[] => {
const cs = window.getComputedStyle(document.body);

if (process.env.NODE_ENV !== 'production') {
if (cs.overflowY === 'hidden') {
console.error(
'react-remove-scroll-bar: cannot calculate scrollbar size because it is removed (overflow:hidden on body'
);
}
}

const left = cs[gapMode === 'padding' ? 'paddingLeft' : 'marginLeft'];
const top = cs[gapMode === 'padding' ? 'paddingTop' : 'marginTop'];
const right = cs[gapMode === 'padding' ? 'paddingRight' : 'marginRight'];
Expand Down

0 comments on commit 3a6aafd

Please sign in to comment.