Created
August 7, 2016 12:10
-
-
Save anonymous/646584a554200730a07c15a11213c8f7 to your computer and use it in GitHub Desktop.
JS Bin // source http://jsbin.com/nabufitipa
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width"> | |
<title>JS Bin</title> | |
<style id="jsbin-css"> | |
body { | |
height:9999px; | |
width:100%; | |
background:black; | |
color:white; | |
} | |
p { | |
position: fixed; | |
} | |
</style> | |
</head> | |
<body> | |
<p id="output">.</p> | |
<script id="jsbin-javascript"> | |
var output = document.getElementById('output'); | |
var barHidden = false; | |
var navHeight = -1; | |
var initialHeight = window.innerHeight; | |
var initialWidth = window.innerWidth; | |
var check = function() { | |
if (initialWidth !== window.innerWidth) { | |
initialHeight = window.innerHeight; | |
initialWidth = window.innerWidth; | |
if (barHidden) { | |
initialHeight -= navHeight; | |
} | |
} | |
var inner = `Inner: ${window.innerHeight}`; | |
var diff = window.innerHeight - initialHeight; | |
if (navHeight === -1 && diff !== 0) { | |
navHeight = Math.abs(diff); | |
} | |
if (diff > 30 && diff < 100) { | |
barHidden = true; | |
} else { | |
barHidden = false; | |
} | |
output.innerText = `Initial: ${initialHeight}\n${inner}\nDiff: ${diff}\nNav Hidden: ${barHidden}`; | |
//window.requestAnimationFrame(check); | |
}; | |
var partialCheck = function() { | |
if (navHeight !== -1) { | |
var percent = ((window.innerHeight - initialHeight) / navHeight) * 100 | |
output.innerText = `${percent}%`; | |
} | |
window.requestAnimationFrame(partialCheck); | |
}; | |
window.onresize = check; | |
check(); | |
window.requestAnimationFrame(partialCheck); | |
</script> | |
<script id="jsbin-source-css" type="text/css">body { | |
height:9999px; | |
width:100%; | |
background:black; | |
color:white; | |
} | |
p { | |
position: fixed; | |
}</script> | |
<script id="jsbin-source-javascript" type="text/javascript">var output = document.getElementById('output'); | |
var barHidden = false; | |
var navHeight = -1; | |
var initialHeight = window.innerHeight; | |
var initialWidth = window.innerWidth; | |
var check = function() { | |
if (initialWidth !== window.innerWidth) { | |
initialHeight = window.innerHeight; | |
initialWidth = window.innerWidth; | |
if (barHidden) { | |
initialHeight -= navHeight; | |
} | |
} | |
var inner = `Inner: ${window.innerHeight}`; | |
var diff = window.innerHeight - initialHeight; | |
if (navHeight === -1 && diff !== 0) { | |
navHeight = Math.abs(diff); | |
} | |
if (diff > 30 && diff < 100) { | |
barHidden = true; | |
} else { | |
barHidden = false; | |
} | |
output.innerText = `Initial: ${initialHeight}\n${inner}\nDiff: ${diff}\nNav Hidden: ${barHidden}`; | |
//window.requestAnimationFrame(check); | |
}; | |
var partialCheck = function() { | |
if (navHeight !== -1) { | |
var percent = ((window.innerHeight - initialHeight) / navHeight) * 100 | |
output.innerText = `${percent}%`; | |
} | |
window.requestAnimationFrame(partialCheck); | |
}; | |
window.onresize = check; | |
check(); | |
window.requestAnimationFrame(partialCheck); | |
</script></body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
body { | |
height:9999px; | |
width:100%; | |
background:black; | |
color:white; | |
} | |
p { | |
position: fixed; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var output = document.getElementById('output'); | |
var barHidden = false; | |
var navHeight = -1; | |
var initialHeight = window.innerHeight; | |
var initialWidth = window.innerWidth; | |
var check = function() { | |
if (initialWidth !== window.innerWidth) { | |
initialHeight = window.innerHeight; | |
initialWidth = window.innerWidth; | |
if (barHidden) { | |
initialHeight -= navHeight; | |
} | |
} | |
var inner = `Inner: ${window.innerHeight}`; | |
var diff = window.innerHeight - initialHeight; | |
if (navHeight === -1 && diff !== 0) { | |
navHeight = Math.abs(diff); | |
} | |
if (diff > 30 && diff < 100) { | |
barHidden = true; | |
} else { | |
barHidden = false; | |
} | |
output.innerText = `Initial: ${initialHeight}\n${inner}\nDiff: ${diff}\nNav Hidden: ${barHidden}`; | |
//window.requestAnimationFrame(check); | |
}; | |
var partialCheck = function() { | |
if (navHeight !== -1) { | |
var percent = ((window.innerHeight - initialHeight) / navHeight) * 100 | |
output.innerText = `${percent}%`; | |
} | |
window.requestAnimationFrame(partialCheck); | |
}; | |
window.onresize = check; | |
check(); | |
window.requestAnimationFrame(partialCheck); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment