//<![CDATA[
/* js/external.js */
let doc, htm, bod, nav, M, I, mobile, S, Q; // for use on other loads
addEventListener('load', ()=>{
doc = document; htm = doc.documentElement; bod = doc.body; nav = navigator; M = tag=>doc.createElement(tag); I = id=>doc.getElementById(id);
mobile = nav.userAgent.match(/Mobi/i) ? true : false;
S = (selector, within)=>{
let w = within || doc;
return w.querySelector(selector);
}
Q = (selector, within)=>{
let w = within || doc;
return w.querySelectorAll(selector);
}
// small library above - magic below can be put on another page using a load Event (except // end load line)
const guts = S('.guts');
let scrollL = 0;
function scrollIt(){
guts.scrollLeft = scrollL;
}
guts.onwheel = function(e){
let d = e.deltaY, w = this.scrollWidth, l = w - innerWidth;
scrollL += d !== undefined && d > 0 ? 100 : -100;
if(scrollL > l){
scrollL = l;
}
else if(scrollL < 0){
scrollL = 0;
}
requestAnimationFrame(scrollIt);
}
}); // end load
//]]>
/* css/external.css */
*{
box-sizing:border-box; font-size:0;
}
html,body,.main{
width:100%; height:100%; background:#333; margin:0;
}
.guts{
width:100%; height:100%; padding:7px; overflow:auto; scroll-behavior:smooth;
}
.guts>div{
width:200%; height:100%; font-size:22px;
}
.guts>div>div{
display:inline-block; width:calc(50% - 3.5px); height:100%;
}
.guts>div>div:first-child{
background:blue;
}
.guts>div>div:last-child{
background:green;
}
<!DOCTYPE html>
<html lang='en'>
<head>
<meta charset='UTF-8' /><meta name='viewport' content='width=device-width, height=device-height, initial-scale:1, user-scalable=no' />
<title>Title Here</title>
<link type='text/css' rel='stylesheet' href='css/external.css' />
<script src='js/external.js'></script>
</head>
<body>
<div class='main'>
<div class='guts'><div><div></div><div></div></div></div>
</div>
</body>
</html>