Skip to content

Instantly share code, notes, and snippets.

@CreatiCoding
Forked from dohoons/getSafeArea.js
Last active April 20, 2020 03:37
Show Gist options
  • Save CreatiCoding/0c32f14101d4ccd565ff782cb996aefc to your computer and use it in GitHub Desktop.
Save CreatiCoding/0c32f14101d4ccd565ff782cb996aefc to your computer and use it in GitHub Desktop.
hasSafeArea()
function hasSafeArea() {
const div = document.createElement('div');
const computed = getComputedStyle(div);
div.style.paddingBottom = 'env(safe-area-inset-bottom)';
document.body.appendChild(div);
const bottom = parseInt(computed.paddingBottom) || 0;
document.body.removeChild(div);
return !!bottom;
}
hasSafeArea();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment