const target = document.querySelector('div') target.addEventListener('wheel', event => { const toLeft = event.deltaY < 0 && target.scrollLeft > 0 const toRight = event.deltaY > 0 && target.scrollLeft < target.scrollWidth - target.clientWidth if (toLeft || toRight) { event.preventDefault() event.stopPropagation() target.scrollLeft += event.deltaY } })
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter