vh-check
vh-check copied to clipboard
isNeeded = false for iPhone/Safari when target=_blank
isNeeded is evaluated to be false when opening a page within a new window, and the whole thing does not work as a result. For me, it happens in iPhone/Safari.
Workaround is to set force: true in the config depending on the User Agent,
or use setTimeout or window.requestAnimationFrame to delay calling vhCheck.
This is my test case.
vh-check.html:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width">
<title>vh-check</title>
<style>
body {
margin: 0px;
padding: 0px;
}
.box {
box-sizing: border-box;
width: 100vw;
height: 100vh;
height: calc(100vh - var(--vh-offset, 0px));
border: 4px solid red;
}
</style>
<script src="https://unpkg.com/[email protected]/dist/vh-check.min.js"></script>
<script>
//window.addEventListener("load", function(){ // load event is still too early
window.requestAnimationFrame(function(){
var result = vhCheck();
document.querySelector("#result").innerText = result.isNeeded;
});
</script>
</head>
<body>
<div class="box">
<p>vhCheck.isNeeded=<span id="result"></span></p>
<a href="vh-check.html" target="_blank">Open New Window</a>
</div>
</body>
</html>
Have the same issue. It fails when you open new tab in Safari and enter url. After reload it works fine. I am tried to use setTimeout, requestAnimationFrame and even calling vh-check after my app fully initialized w/o any success. It still fails sometimes.