Skip to content

Commit

Permalink
fix: lock body scroll when using webkit (#3399)
Browse files Browse the repository at this point in the history
  • Loading branch information
OwsleyJr committed May 11, 2023
1 parent 4bd8764 commit c27f960
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/hooks/useLockBodyScroll.ts
Expand Up @@ -15,13 +15,20 @@ export const useLockBodyScroll = (
disabled?: boolean
): void => {
useEffect(() => {
const originalStyle = window.getComputedStyle(document.body).overflow;
const originalOverflowStyle = window.getComputedStyle(
document.body
).overflow;
const originalTouchActionStyle = window.getComputedStyle(
document.body
).touchAction;
if (isLocked && !disabled) {
document.body.style.overflow = 'hidden';
document.body.style.touchAction = 'none';
}
return () => {
if (!disabled) {
document.body.style.overflow = originalStyle;
document.body.style.overflow = originalOverflowStyle;
document.body.style.touchAction = originalTouchActionStyle;
}
};
}, [isLocked, disabled]);
Expand Down

0 comments on commit c27f960

Please sign in to comment.