can you make a website which scrolls diagonally, instead of straight up/down
Browse filesFiles changed (6)
- README.md+8-5
- components/footer.jsAdded+28
- components/navbar.jsAdded+71
- index.html+53-19
- script.jsAdded+51
- style.css+27-18
12345678910---title: Diagonal Scroll Delightemoji: 🏢colorFrom: purplecolorTo: purplesdk: staticpinned: false---Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference12345678910111213---title: Diagonal Scroll Delight 🌀colorFrom: yellowcolorTo: greenemoji: 🐳sdk: staticpinned: falsetags:- deepsite-v3---# Welcome to your new DeepSite project!This project was created with [DeepSite](https://deepsite.hf.co).
12345678910111213141516171819202122232425262728class DiagonalFooter extends HTMLElement { connectedCallback() { this.attachShadow({ mode: 'open' }); this.shadowRoot.innerHTML = ` <style> footer { position: fixed; bottom: 0; left: 0; width: 100%; padding: 1.5rem; text-align: center; z-index: 100; mix-blend-mode: difference; } p { color: white; font-size: 0.9rem; opacity: 0.8; } </style> <footer> <p>© ${new Date().getFullYear()} Diagonal Scroll Experience. All rights reserved.</p> </footer> `; }}customElements.define('diagonal-footer', DiagonalFooter);1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071class DiagonalNavbar extends HTMLElement { connectedCallback() { this.attachShadow({ mode: 'open' }); this.shadowRoot.innerHTML = ` <style> nav { position: fixed; top: 0; left: 0; width: 100%; padding: 1.5rem; display: flex; justify-content: space-between; align-items: center; z-index: 100; mix-blend-mode: difference; } .logo { color: white; font-weight: bold; font-size: 1.5rem; text-transform: uppercase; letter-spacing: 0.1em; } .nav-links { display: flex; gap: 2rem; list-style: none; margin: 0; padding: 0; } a { color: white; text-decoration: none; font-weight: 500; position: relative; } a:after { content: ''; position: absolute; width: 100%; height: 2px; bottom: -4px; left: 0; background-color: white; transform: scaleX(0); transform-origin: bottom right; transition: transform 0.3s ease; } a:hover:after { transform: scaleX(1); transform-origin: bottom left; } @media (max-width: 768px) { .nav-links { display: none; } } </style> <nav> <div class="logo">Diagonal</div> <ul class="nav-links"> <li><a href="#">Home</a></li> <li><a href="#">About</a></li> <li><a href="#">Contact</a></li> </ul> </nav> `; }}customElements.define('diagonal-navbar', DiagonalNavbar);12345678910111213141516171819<!doctype html><html><head><meta charset="utf-8" /><meta name="viewport" content="width=device-width" /><title>My static Space</title><link rel="stylesheet" href="style.css" /></head><body><div class="card"><h1>Welcome to your static Space!</h1><p>You can modify this app directly by editing <i>index.html</i> in the Files and versions tab.</p><p>Also don't forget to check the<a href="https://huggingface.co/docs/hub/spaces" target="_blank">Spaces documentation</a>.</p></div></body></html>1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>Diagonal Scroll</title><link rel="stylesheet" href="style.css"><script src="https://cdn.tailwindcss.com"></script><script src="https://unpkg.com/feather-icons"></script><script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.12.2/gsap.min.js"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.12.2/ScrollTrigger.min.js"></script></head><body class="overflow-hidden"><div id="diagonal-scroll-container" class="fixed w-screen h-screen"><div id="content-wrapper" class="absolute origin-top-left"><section class="panel bg-gradient-to-br from-indigo-500 to-purple-600 w-screen h-screen flex items-center justify-center"><div class="text-center max-w-2xl px-4"><h1 class="text-5xl md:text-7xl font-bold text-white mb-6">Scroll Diagonally</h1><p class="text-xl text-white opacity-90 mb-8">A unique scrolling experience that breaks the vertical convention</p><div class="animate-bounce"><i data-feather="arrow-down-right" class="text-white w-12 h-12"></i></div></div></section><section class="panel bg-gradient-to-br from-amber-500 to-pink-500 w-screen h-screen flex items-center justify-center"><div class="text-center max-w-2xl px-4"><h2 class="text-4xl md:text-6xl font-bold text-white mb-6">How Does It Work?</h2><p class="text-xl text-white opacity-90 mb-8">We're using GSAP's ScrollTrigger to transform the viewport on scroll</p></div></section><section class="panel bg-gradient-to-br from-emerald-500 to-teal-600 w-screen h-screen flex items-center justify-center"><div class="text-center max-w-2xl px-4"><h2 class="text-4xl md:text-6xl font-bold text-white mb-6">Try Scrolling</h2><p class="text-xl text-white opacity-90 mb-8">Notice how the content moves diagonally instead of vertically</p></div></section><section class="panel bg-gradient-to-br from-rose-500 to-fuchsia-600 w-screen h-screen flex items-center justify-center"><div class="text-center max-w-2xl px-4"><h2 class="text-4xl md:text-6xl font-bold text-white mb-6">Mobile Friendly</h2><p class="text-xl text-white opacity-90">This effect works on all device sizes</p></div></section></div></div><script src="script.js"></script><script>feather.replace();</script><script src="https://deepsite.hf.co/deepsite-badge.js"></script></body></html>
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051document.addEventListener('DOMContentLoaded', () => { // Initialize GSAP and ScrollTrigger gsap.registerPlugin(ScrollTrigger);
// Get the elements const container = document.getElementById('diagonal-scroll-container'); const contentWrapper = document.getElementById('content-wrapper'); const panels = gsap.utils.toArray('.panel');
// Calculate total width and height of all panels const totalWidth = window.innerWidth * panels.length; const totalHeight = window.innerHeight * panels.length;
// Set up the diagonal scroll effect gsap.to(contentWrapper, { x: () => -Math.sqrt(2) * (totalWidth - window.innerWidth), y: () => -Math.sqrt(2) * (totalHeight - window.innerHeight), ease: 'none', scrollTrigger: { trigger: container, start: 'top top', end: () => `+=${Math.sqrt(totalWidth * totalWidth + totalHeight * totalHeight)}`, scrub: 1, pin: true, anticipatePin: 1 } });
// Rotate the container for diagonal scrolling gsap.set(contentWrapper, { rotation: 45, width: totalWidth * Math.sqrt(2), height: totalHeight * Math.sqrt(2), xPercent: -50, yPercent: -50 });
// Handle resize events window.addEventListener('resize', () => { ScrollTrigger.refresh(); });
// Smooth scroll to next panel on arrow click document.querySelector('.animate-bounce').addEventListener('click', () => { gsap.to(window, { scrollTo: window.innerHeight * 0.8, duration: 1.5, ease: 'power2.inOut' }); });});12345678910111213141516171819202122232425262728body {padding: 2rem;font-family: -apple-system, BlinkMacSystemFont, "Arial", sans-serif;}h1 {font-size: 16px;margin-top: 0;}p {color: rgb(107, 114, 128);font-size: 15px;margin-bottom: 10px;margin-top: 5px;}.card {max-width: 620px;margin: 0 auto;padding: 16px;border: 1px solid lightgray;border-radius: 16px;}.card p:last-child {margin-bottom: 0;}12345678910111213141516171819202122232425262728293031323334353637/* Reset some default styles */* {margin: 0;padding: 0;box-sizing: border-box;}/* Basic styles */body {font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;-webkit-font-smoothing: antialiased;-moz-osx-font-smoothing: grayscale;}.panel {position: relative;overflow: hidden;}/* Custom scrollbar */::-webkit-scrollbar {width: 8px;height: 8px;}::-webkit-scrollbar-track {background: rgba(0, 0, 0, 0.1);}::-webkit-scrollbar-thumb {background: rgba(255, 255, 255, 0.5);border-radius: 4px;}::-webkit-scrollbar-thumb:hover {background: rgba(255, 255, 255, 0.7);}
README.md+8-5
components/footer.jsAdded+28
components/navbar.jsAdded+71
index.html+53-19
script.jsAdded+51
style.css+27-18