Skip to content

Commit

Permalink
scroller
Browse files Browse the repository at this point in the history
  • Loading branch information
mathieukvogt committed Sep 27, 2024
1 parent 059f02f commit 3dd0305
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 6 deletions.
9 changes: 9 additions & 0 deletions main.css
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,15 @@ h2 {
text-decoration: none;
}

.scroller {
scrollbar-width: none; /* For Firefox */
}

.scroller::-webkit-scrollbar {
display: none; /* For Chrome, Safari, and Opera */
}


.tooltip {
position: relative;
cursor: pointer;
Expand Down
25 changes: 19 additions & 6 deletions script.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,19 @@ document.addEventListener("DOMContentLoaded", function () {
});
});

// Add horizontal scrolling with mouse wheel for desktop devices
if (window.matchMedia("(pointer: fine)").matches) {
const scroller = document.querySelector(".scroller");

scroller.addEventListener("wheel", function (e) {
// Prevent the default vertical scroll behavior
e.preventDefault();

// Scroll horizontally by the amount of vertical scrolling
scroller.scrollLeft += e.deltaY;
});
}

const darkModeButton = document.getElementById("darkModeButton");
const leftHalf = darkModeButton.querySelector(".half.left");
const rightHalf = darkModeButton.querySelector(".half.right");
Expand Down Expand Up @@ -59,6 +72,7 @@ document.addEventListener("DOMContentLoaded", function () {
document.querySelector(".overlay").style.display = "none";
},
});

// Select the burger button and menu bars
const burgerButton = document.querySelector(".burger");
const menuBars = document.querySelectorAll(".menu-bar");
Expand All @@ -74,7 +88,7 @@ document.addEventListener("DOMContentLoaded", function () {
gsap.to(menuBars, {
duration: 0.5,
y: "0%",
stagger: 0.05, // Delay each bar by 0.1s
stagger: 0.05, // Delay each bar by 0.05s
ease: "power4.out",
});
gsap.to(menuOverlay, {
Expand All @@ -99,10 +113,9 @@ document.addEventListener("DOMContentLoaded", function () {
});
}
});
});

const burgerButton = document.querySelector(".burger");

burgerButton.addEventListener("click", () => {
burgerButton.classList.toggle("rotate");
// Rotate the burger button on click
burgerButton.addEventListener("click", () => {
burgerButton.classList.toggle("rotate");
});
});

0 comments on commit 3dd0305

Please sign in to comment.