Skip to content

Commit

Permalink
Much ado about nothing.
Browse files Browse the repository at this point in the history
  • Loading branch information
DeboAtWinterlight committed Aug 25, 2024
1 parent 0c2809a commit a8eb760
Showing 1 changed file with 0 additions and 29 deletions.
29 changes: 0 additions & 29 deletions main.js
Original file line number Diff line number Diff line change
@@ -1,29 +0,0 @@
document.addEventListener("load", function () {
const scrollableArea = document.getElementById("scrollable-area");

// Prevent default touch behavior to allow custom scrolling
scrollableArea.addEventListener(
"touchmove",
function (e) {
e.preventDefault();
},
{ passive: false }
);

let startX, startY, scrollLeft, scrollTop;

scrollableArea.addEventListener("touchstart", function (e) {
startX = e.touches[0].pageX - scrollableArea.offsetLeft;
startY = e.touches[0].pageY - scrollableArea.offsetTop;
scrollLeft = window.pageXOffset || document.documentElement.scrollLeft;
scrollTop = window.pageYOffset || document.documentElement.scrollTop;
});

scrollableArea.addEventListener("touchmove", function (e) {
const x = e.touches[0].pageX - scrollableArea.offsetLeft;
const y = e.touches[0].pageY - scrollableArea.offsetTop;
const walkX = (x - startX) * 2; // Adjust scrolling speed if needed
const walkY = (y - startY) * 2;
window.scrollTo(scrollLeft - walkX, scrollTop - walkY);
});
});

0 comments on commit a8eb760

Please # to comment.