-
-
Save pguerrant/e959c47a6b1d4b841cc3267a61950f33 to your computer and use it in GitHub Desktop.
iOS/Safari bug - when using -webkit-overflow-scrolling:touch, visual scroll position is reset on the non-scrolling axis when user begins scrolling
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> | |
<style> | |
#container { | |
background: yellowgreen; | |
height: 400px; | |
width: 400px; | |
overflow-x: auto; | |
overflow-y: hidden; | |
-webkit-overflow-scrolling: touch; | |
} | |
#content { | |
background: green; | |
height: 200px; | |
width: 200px; | |
margin: 350px; | |
} | |
</style> | |
</head> | |
<body> | |
<!-- Attempt to scroll this element, the vertical scroll position immediately jumps to 0 --> | |
<div id="container"> | |
<div id="content"></div> | |
</div> | |
<script> | |
(function() { | |
var container = document.getElementById('container'); | |
container.scrollTop = 150; | |
container.scrollLeft = 150; | |
})(); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment