Skip to content

Instantly share code, notes, and snippets.

@tlancina
Last active March 7, 2019 23:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tlancina/694e54d8c357834f6fc0681586cdb460 to your computer and use it in GitHub Desktop.
Save tlancina/694e54d8c357834f6fc0681586cdb460 to your computer and use it in GitHub Desktop.
Minimal reproduction of scrolling issue in WKWebView on iOS 12.2 with `pointer-events: none` when using `-webkit-overflow-scrolling: touch`
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta name="viewport" content="viewport-fit=cover, width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
<style>
html, body {
width: 100%;
height: 100%;
}
body {
position: fixed;
}
.scroll-bug-container {
left: 0;
right: 0;
top: 20px;
bottom: 0;
position: absolute;
display: block;
overflow-y: scroll;
-webkit-overflow-scrolling: touch;
}
</style>
<script>
function freeze() {
document.querySelector('.scroll-bug-container').style.backgroundColor = "gray";
document.querySelector('.scroll-bug-container').style.pointerEvents = "none";
setTimeout(() => {
document.querySelector('.scroll-bug-container').style.pointerEvents = "";
}, 750);
}
function unfreeze() {
// triggering any style change causes normal scroll behavior to resume
document.querySelector('.scroll-bug-container').style.backgroundColor = "";
}
</script>
</head>
<body>
<div class="scroll-bug-container">
<button onclick="freeze()">Freeze</button>
<button onclick="unfreeze()">Unfreeze</button>
<div>Item</div>
<div>Item</div>
<div>Item</div>
<div>Item</div>
<div>Item</div>
<div>Item</div>
<div>Item</div>
<div>Item</div>
<div>Item</div>
<div>Item</div>
<div>Item</div>
<div>Item</div>
<div>Item</div>
<div>Item</div>
<div>Item</div>
<div>Item</div>
<div>Item</div>
<div>Item</div>
<div>Item</div>
<div>Item</div>
<div>Item</div>
<div>Item</div>
<div>Item</div>
<div>Item</div>
<div>Item</div>
<div>Item</div>
<div>Item</div>
<div>Item</div>
<div>Item</div>
<div>Item</div>
<div>Item</div>
<div>Item</div>
<div>Item</div>
<div>Item</div>
<div>Item</div>
<div>Item</div>
<div>Item</div>
<div>Item</div>
<div>Item</div>
<div>Item</div>
<div>Item</div>
<div>Item</div>
<div>Item</div>
</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment