Skip to content

Commit

Permalink
fix: remove measure time error reporting, fixes #35
Browse files Browse the repository at this point in the history
  • Loading branch information
theKashey committed Oct 12, 2022
1 parent 3dd80e2 commit 3f4bf5d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
5 changes: 5 additions & 0 deletions src/component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ const getStyles = (
*/
export const RemoveScrollBar: React.FC<BodyScroll> = (props) => {
const { noRelative, noImportant, gapMode = 'margin' } = props;
/*
gap will be measured on every component mount
however it will be used only by the "first" invocation
due to singleton nature of <Style
*/
const gap = React.useMemo(() => getGapWidth(gapMode), [gapMode]);

return <Style styles={getStyles(gap, !noRelative, gapMode, !noImportant ? '!important' : '')} />;
Expand Down
8 changes: 0 additions & 8 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,6 @@ 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 3f4bf5d

Please sign in to comment.