-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
400 additions
and
48 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
html, | ||
body { | ||
height: 100%; /* Ensure the body takes full height */ | ||
overflow: hidden; /* Prevent default scrolling */ | ||
} | ||
|
||
.section { | ||
height: 100vh; /* Each section takes full viewport height */ | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
flex-direction: column; | ||
scroll-snap-align: start; /* Align sections for snapping */ | ||
padding: 20px; | ||
text-align: center; | ||
} | ||
|
||
.section * { | ||
max-width: 80%; | ||
} | ||
|
||
.section h2 { | ||
font-size: 2rem; | ||
margin-bottom: 1rem; | ||
} | ||
|
||
.section p { | ||
font-size: 1.2rem; | ||
margin: 0.5rem 0; | ||
} | ||
|
||
.section ul { | ||
list-style-type: none; | ||
padding: 0; | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
width: 100%; | ||
} | ||
|
||
.section ul li { | ||
font-size: 1.1rem; | ||
margin: 0.5rem 0; | ||
text-align: center; | ||
width: 100%; | ||
} | ||
|
||
.cta-button { | ||
background-color: var(--background-color); | ||
color: var(--text-color); | ||
padding: 10px 20px; | ||
text-decoration: none; | ||
border-radius: 5px; | ||
transition: background-color 0.3s; | ||
} | ||
|
||
.cta-button:hover { | ||
background-color: color-mix(in srgb, var(--hover-color) 80%, var(--effortless-white)); | ||
} | ||
|
||
.arrow { | ||
font-size: 2rem; | ||
color: var(--primary-color); | ||
cursor: pointer; | ||
position: fixed; | ||
z-index: 1000; | ||
opacity: 0; | ||
transition: opacity 0.3s ease, color 0.3s ease; | ||
} | ||
.up-arrow { | ||
top: 90px; | ||
left: 50%; | ||
transform: translateX(-50%); | ||
} | ||
.down-arrow { | ||
bottom: 20px; | ||
left: 50%; | ||
transform: translateX(-50%); | ||
} | ||
|
||
.show { | ||
opacity: 1; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
document.addEventListener("templateConstructed", function () { | ||
const sections = document.querySelectorAll(".section"); | ||
const upArrow = document.getElementById("upArrow"); | ||
const downArrow = document.getElementById("downArrow"); | ||
let currentSection = 0; | ||
let isScrolling = false; | ||
let scrollTimer = null; | ||
|
||
function updateSectionColors() { | ||
sections.forEach((section, index) => { | ||
section.style.backgroundColor = | ||
index % 2 === 0 | ||
? "var(--background-color)" | ||
: "var(--effortless-blue)"; | ||
}); | ||
} | ||
|
||
function updateArrowColors() { | ||
var currentSectionColor = getComputedStyle(sections[currentSection]).backgroundColor; | ||
var backgroundColorHex = getComputedStyle(document.documentElement).getPropertyValue("--background-color").trim(); | ||
var backgroundColorRgb = hexToRgb(backgroundColorHex); | ||
console.log(currentSectionColor); | ||
var arrowColor = currentSectionColor === backgroundColorRgb | ||
? "var(--primary-color)" | ||
: "var(--background-color)"; | ||
|
||
upArrow.style.color = arrowColor; | ||
downArrow.style.color = arrowColor; | ||
} | ||
|
||
function updateArrowVisibility() { | ||
upArrow.classList.toggle("show", currentSection > 0); | ||
downArrow.classList.toggle("show", currentSection < sections.length - 1); | ||
} | ||
|
||
function scrollToSection(index) { | ||
if (index < 0 || index >= sections.length || isScrolling) return; | ||
|
||
sections[index].scrollIntoView({ behavior: "smooth" }); | ||
isScrolling = true; | ||
setTimeout(() => { | ||
isScrolling = false; | ||
currentSection = index; | ||
updateArrowVisibility(); | ||
updateArrowColors(); | ||
}, 750); | ||
} | ||
|
||
function handleScroll(direction) { | ||
const newSection = currentSection + direction; | ||
scrollToSection(newSection); | ||
} | ||
|
||
function queueScroll(direction) { | ||
if (!scrollTimer) { | ||
handleScroll(direction); | ||
} | ||
clearTimeout(scrollTimer); | ||
scrollTimer = setTimeout(() => { | ||
scrollTimer = null; | ||
}, 50); | ||
} | ||
|
||
window.addEventListener("wheel", (event) => { | ||
const direction = event.deltaY > 0 ? 1 : -1; | ||
queueScroll(direction); | ||
}); | ||
|
||
let touchStartY = 0; | ||
window.addEventListener("touchstart", (event) => { | ||
touchStartY = event.touches[0].clientY; | ||
}); | ||
|
||
window.addEventListener("touchmove", (event) => { | ||
const touchEndY = event.touches[0].clientY; | ||
const difference = touchStartY - touchEndY; | ||
if (Math.abs(difference) > 50) { | ||
const direction = difference > 0 ? 1 : -1; | ||
queueScroll(direction); | ||
} | ||
}); | ||
|
||
window.addEventListener("keydown", (event) => { | ||
if (event.key === "ArrowUp") { | ||
handleScroll(-1); | ||
} else if (event.key === "ArrowDown") { | ||
handleScroll(1); | ||
} | ||
}); | ||
|
||
upArrow.addEventListener("click", () => handleScroll(-1)); | ||
downArrow.addEventListener("click", () => handleScroll(1)); | ||
updateSectionColors(); | ||
setTimeout(() => { | ||
updateArrowVisibility(); | ||
updateArrowColors(); | ||
}, 750); | ||
}); | ||
|
||
// Helper function to convert hex to rgb | ||
function hexToRgb(hex) { | ||
hex = hex.replace(/^#/, ""); | ||
var bigint = parseInt(hex, 16); | ||
var r = (bigint >> 16) & 255; | ||
var g = (bigint >> 8) & 255; | ||
var b = bigint & 255; | ||
return `rgb(${r}, ${g}, ${b})`; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.