Skip to content

Commit

Permalink
Sunday 2
Browse files Browse the repository at this point in the history
  • Loading branch information
MichelKerkmeester committed Jan 26, 2025
1 parent 61422a5 commit 6ba689f
Show file tree
Hide file tree
Showing 5 changed files with 120 additions and 9 deletions.
Binary file modified .DS_Store
Binary file not shown.
77 changes: 68 additions & 9 deletions code/1__PAGES/--GLOBAL/global.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -122,19 +122,66 @@
"JS | Footer (Before)\n",
"____________________\n",
"\n",
"<!-- Change Page Title on Leave -->\n",
"<script>\n",
" const documentTitleStore = document.title;\n",
" const documentTitleOnBlur = \"Spring aan boord! 🚢\";\n",
"\n",
" // Set original title if user is on the site\n",
" window.addEventListener(\"focus\", () => {\n",
" document.title = documentTitleStore;\n",
" });\n",
"\n",
" // If user leaves tab, set the alternative title\n",
" window.addEventListener(\"blur\", () => {\n",
" document.title = documentTitleOnBlur;\n",
" });\n",
"</script>\n",
"\n",
"<!-- Automatically change copyright year -->\n",
"<script>\n",
" document.querySelectorAll(\".copyright--year\").forEach((element) => {\n",
" element.textContent = new Date().getFullYear(); // Update the text content of each element\n",
" });\n",
"</script>\n",
"\n",
"<!-- Lenis.js - Smooth Scrolling -->\n",
"<script data-id-scroll data-autoinit=\"true\" data-duration=\"1\" data-orientation=\"vertical\" data-smoothWheel=\"true\"\n",
" data-smoothTouch=\"false\" data-touchMultiplier=\"1.5\" data-easing=\"(t) => (t === 1 ? 1 : 1 - Math.pow(2, -10 * t))\"\n",
" data-useOverscroll=\"true\" data-useControls=\"true\" data-useAnchor=\"true\" data-useRaf=\"true\" data-infinite=\"false\"\n",
" defer\n",
" src=\"https://uploads-ssl.webflow.com/645e0e1ff7fdb6dc8c85f3a2/653b82ecf87f552a98ac66b9_lenis-master-offbrand.02.txt\"></script>\n",
"<!-- Navigation -->\n",
"<!-- Hide Nav on Scroll -->\n",
"<script>\n",
" document.addEventListener('DOMContentLoaded', function () {\n",
" let lastScrollTop = 0;\n",
" const navbar = document.querySelector('.nav--bar');\n",
" const scrollThreshold = 50; // Minimum scroll amount before hiding/showing\n",
" const mobileBreakpoint = 768; // Adjust this based on your mobile breakpoint\n",
"\n",
" function handleScroll() {\n",
" // Only run on desktop\n",
" if (window.innerWidth <= mobileBreakpoint) return;\n",
"\n",
" const currentScroll = window.pageYOffset || document.documentElement.scrollTop;\n",
"\n",
" // Check if user has scrolled more than threshold\n",
" if (Math.abs(lastScrollTop - currentScroll) <= scrollThreshold) return;\n",
"\n",
" // Scrolling down & not at the top\n",
" if (currentScroll > lastScrollTop && currentScroll > 50) {\n",
" navbar.style.transform = 'translateY(-200%)';\n",
" }\n",
" // Scrolling up\n",
" else {\n",
" navbar.style.transform = 'translateY(0)';\n",
" }\n",
"\n",
" lastScrollTop = currentScroll;\n",
" }\n",
"\n",
" // Add smooth transition to the navbar\n",
" navbar.style.transition = 'transform 0.3s ease-in-out';\n",
"\n",
" // Add scroll event listener\n",
" window.addEventListener('scroll', handleScroll, { passive: true });\n",
" });\n",
"</script>\n",
"\n",
"<!-- Navigation -->\n",
"<!-- Mobile — Mega Menu -->\n",
Expand All @@ -154,6 +201,7 @@
"\n",
" // Function to open the menu\n",
" function openMenu() {\n",
" megaMenu.style.display = 'flex'; // Set display to flex before animation\n",
" gsap.to(megaMenu, {\n",
" duration: 0.8,\n",
" height: '100svh',\n",
Expand All @@ -165,7 +213,6 @@
" },\n",
" });\n",
" lottieAnimation.playSegments([0, 70], true);\n",
" lottieAnimation.setSpeed(1.5);\n",
" }\n",
"\n",
" // Function to close the menu\n",
Expand All @@ -176,9 +223,14 @@
" height: '0svh',\n",
" width: '100%',\n",
" ease: 'power2.in',\n",
" onComplete: () => {\n",
" megaMenu.style.display = 'none'; // Hide menu after animation completes\n",
" },\n",
" });\n",
" lottieAnimation.playSegments([70, 140], true);\n",
" lottieAnimation.setSpeed(1.5);\n",
" lottieAnimation.addEventListener('complete', () => {\n",
" lottieAnimation.goToAndStop(0, true);\n",
" });\n",
" }\n",
"\n",
" // Toggle menu on button click\n",
Expand Down Expand Up @@ -487,7 +539,14 @@
" }\n",
" });\n",
" });\n",
"</script>"
"</script>\n",
"\n",
"<!-- Lenis.js - Smooth Scrolling -->\n",
"<script data-id-scroll data-autoinit=\"true\" data-duration=\"1\" data-orientation=\"vertical\" data-smoothWheel=\"true\"\n",
" data-smoothTouch=\"false\" data-touchMultiplier=\"1.5\" data-easing=\"(t) => (t === 1 ? 1 : 1 - Math.pow(2, -10 * t))\"\n",
" data-useOverscroll=\"true\" data-useControls=\"true\" data-useAnchor=\"true\" data-useRaf=\"true\" data-infinite=\"false\"\n",
" defer\n",
" src=\"https://uploads-ssl.webflow.com/645e0e1ff7fdb6dc8c85f3a2/653b82ecf87f552a98ac66b9_lenis-master-offbrand.02.txt\"></script>"
]
}
],
Expand Down
35 changes: 35 additions & 0 deletions code/2__COMPONENTS/--NAVIGATION/hide-nav-on-scroll.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// Navigation
// Hide Nav on Scroll
document.addEventListener('DOMContentLoaded', function () {
let lastScrollTop = 0;
const navbar = document.querySelector('.nav--bar');
const scrollThreshold = 50; // Minimum scroll amount before hiding/showing
const mobileBreakpoint = 768; // Adjust this based on your mobile breakpoint

function handleScroll() {
// Only run on desktop
if (window.innerWidth <= mobileBreakpoint) return;

const currentScroll = window.pageYOffset || document.documentElement.scrollTop;

// Check if user has scrolled more than threshold
if (Math.abs(lastScrollTop - currentScroll) <= scrollThreshold) return;

// Scrolling down & not at the top
if (currentScroll > lastScrollTop && currentScroll > 50) {
navbar.style.transform = 'translateY(-200%)';
}
// Scrolling up
else {
navbar.style.transform = 'translateY(0)';
}

lastScrollTop = currentScroll;
}

// Add smooth transition to the navbar
navbar.style.transition = 'transform 0.3s ease-in-out';

// Add scroll event listener
window.addEventListener('scroll', handleScroll, { passive: true });
});
4 changes: 4 additions & 0 deletions code/2__COMPONENTS/--NAVIGATION/mega-menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const lottieAnimation = lottie.loadAnimation({

// Function to open the menu
function openMenu() {
megaMenu.style.display = 'flex'; // Set display to flex before animation
gsap.to(megaMenu, {
duration: 0.8,
height: '100svh',
Expand All @@ -37,6 +38,9 @@ function closeMenu() {
height: '0svh',
width: '100%',
ease: 'power2.in',
onComplete: () => {
megaMenu.style.display = 'none'; // Hide menu after animation completes
},
});
lottieAnimation.playSegments([70, 140], true);
lottieAnimation.addEventListener('complete', () => {
Expand Down
13 changes: 13 additions & 0 deletions code/2__COMPONENTS/--OTHER/change-page-title-on-leave.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Change Page Title on Leave
const documentTitleStore = document.title;
const documentTitleOnBlur = '🚢 Mis de boot niet';

// Set original title if user is on the site
window.addEventListener('focus', () => {
document.title = documentTitleStore;
});

// If user leaves tab, set the alternative title
window.addEventListener('blur', () => {
document.title = documentTitleOnBlur;
});

0 comments on commit 6ba689f

Please sign in to comment.