Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue in IOS 15 Safari that bottom blank bar will show up #242

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/bodyScrollLock.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,14 +113,16 @@ const setPositionFixed = () => window.requestAnimationFrame(() => {
previousBodyPosition = {
position: document.body.style.position,
top: document.body.style.top,
left: document.body.style.left
left: document.body.style.left,
height: document.documentElement.style.height
};

// Update the dom inside an animation frame
const { scrollY, scrollX, innerHeight } = window;
document.body.style.position = 'fixed';
document.body.style.top = `${-scrollY}px`;
document.body.style.left = `${-scrollX}px`;
document.documentElement.style.height = '100vh';

setTimeout(() => window.requestAnimationFrame(() => {
// Attempt to check if the bottom bar appeared due to the position change
Expand All @@ -143,6 +145,7 @@ const restorePositionSetting = () => {
document.body.style.position = previousBodyPosition.position;
document.body.style.top = previousBodyPosition.top;
document.body.style.left = previousBodyPosition.left;
document.documentElement.style.height = previousBodyPosition.height;

// Restore scroll
window.scrollTo(x, y);
Expand Down