I am using the following code with a JS .scroll to detect when the bottom viewport scroll bar is being scrolled sideways (and then do something based on that event). It doesn't trigger when I target the HTML tag, but if I target the BODY tag with the .scroll, it does trigger.
The problem I'm seeing with the BODY tag scroll bar, is that it will only show up if you scroll all the way to the bottom of the 5000px I have the inner div set to. With what I believe is the natural, HTML-bottom-of-the-viewport-scroll-bar, it's always just sitting at the bottom of the browser window if there's something to scroll to, but I don't know how to detect it moving.
Is there a way for .scroll to detect it being scrolled, or is there another method that can detect if the viewport is scrolling sideways?
<html>
<head>
<title>Side Scroll</title>
<script src="js/jquery.min.js"></script>
</head>
<body>
<style>
.extra_wide_div {
width: 6000px;
height: 5000px;
background: linear-gradient(to right, red , yellow);
}
html {
overflow-x: auto;
overflow-y: auto;
}
body {
/*
overflow-x: auto;
overflow-y: hidden;
*/
}
</style>
<div class="extra_wide_div">
Hello
</div>
<script>
$scrollTarget = $('html');
$scrollTarget.scroll(function(e) {
console.log("scroll triggered");
});
</script>
</body>
</html>