Hi so this is the page I will be talking about: https://wordpress-776730-2792401.cloudwaysapps.com/demo-horizontal-scrol/
I have a horizontal scroll on it which I want to disable for mobile devices (tablet and phone). This is the code i for the horizontal scroll:
<script type="text/javascript">
if (window.innerWidth > 1025) {
const scrollContainer = document.querySelector("main");
scrollContainer.addEventListener("wheel", (evt) => {
evt.preventDefault();
scrollContainer.scrollLeft += evt.deltaY;
});
} else {
}
</script>
This is the code i used to disable it but it also disables desktop horizontal scroll:
<script type="text/javascript"> function isMobile() { return /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent); } if (!isMobile()) { <script type="text/javascript">
if (window.innerWidth > 1025) {
const scrollContainer = document.querySelector("main");
scrollContainer.addEventListener("wheel", (evt) => {
evt.preventDefault();
scrollContainer.scrollLeft += evt.deltaY;
});
} else {
}
</script>
PLEASE HELP :)