Spaces:
Paused
Paused
Download static/js/arrival.js from igardner/StockAnalysis: direct link, hf CLI and curl.
- Browser
- Download file 6.33 kB
-
https://huggingface.co/spaces/igardner/StockAnalysis/resolve/main/static/js/arrival.js
- Command line
-
hf download hf://spaces/igardner/StockAnalysis/static/js/arrival.js
-
curl -L -o arrival.js https://huggingface.co/spaces/igardner/StockAnalysis/resolve/main/static/js/arrival.js
6.33 kB
| /* GSAP-led parlor transitions, with a native CSS/reduced-motion fallback. */ | |
| (function () { | |
| const overlay = document.getElementById('scene-transition'); | |
| const leftDoor = overlay && overlay.querySelector('.scene-door-left'); | |
| const rightDoor = overlay && overlay.querySelector('.scene-door-right'); | |
| const core = overlay && overlay.querySelector('.scene-core'); | |
| const caption = document.getElementById('scene-caption'); | |
| const title = document.getElementById('scene-title'); | |
| const gsap = window.gsap; | |
| let reducedMotion = window.matchMedia('(prefers-reduced-motion: reduce)').matches; | |
| let transitionRunning = false; | |
| if (gsap && gsap.matchMedia) { | |
| const media = gsap.matchMedia(); | |
| media.add({ reduceMotion: '(prefers-reduced-motion: reduce)' }, function (context) { | |
| reducedMotion = context.conditions.reduceMotion; | |
| }); | |
| } | |
| function showScene(sceneCaption, sceneTitle) { | |
| if (!overlay) return false; | |
| caption.textContent = sceneCaption; | |
| title.textContent = sceneTitle; | |
| overlay.hidden = false; | |
| overlay.setAttribute('aria-hidden', 'false'); | |
| overlay.dataset.active = 'true'; | |
| return true; | |
| } | |
| function hideScene() { | |
| if (!overlay) return; | |
| overlay.hidden = true; | |
| overlay.setAttribute('aria-hidden', 'true'); | |
| overlay.dataset.active = 'false'; | |
| overlay.classList.remove('is-active', 'is-closing', 'is-opening', 'is-closed'); | |
| } | |
| function enterRoom(url) { | |
| if (transitionRunning || !url) return; | |
| transitionRunning = true; | |
| try { sessionStorage.setItem('parlor:arrival', '1'); } catch (_) { /* storage may be disabled */ } | |
| if (!showScene('THE MIDNIGHT PARLOR', 'A seat has been kept for you.')) { | |
| location.assign(url); | |
| return; | |
| } | |
| const navigate = function () { location.assign(url); }; | |
| if (!gsap || reducedMotion) { | |
| overlay.classList.add('is-active', 'is-closing'); | |
| window.setTimeout(navigate, reducedMotion ? 120 : 760); | |
| return; | |
| } | |
| gsap.set(overlay, { autoAlpha: 1 }); | |
| gsap.set(leftDoor, { xPercent: -100 }); | |
| gsap.set(rightDoor, { xPercent: 100 }); | |
| gsap.set(core, { autoAlpha: 0, y: 18, scale: 0.96 }); | |
| gsap.timeline({ defaults: { ease: 'power3.inOut' }, onComplete: navigate }) | |
| .to(leftDoor, { xPercent: 0, duration: 0.78 }, 0) | |
| .to(rightDoor, { xPercent: 0, duration: 0.78 }, 0.04) | |
| .to(core, { autoAlpha: 1, y: 0, scale: 1, duration: 0.48, ease: 'power2.out' }, 0.38) | |
| .to(core, { autoAlpha: 0, y: -10, duration: 0.2 }, 1.12); | |
| } | |
| function revealRoom() { | |
| let arriving = false; | |
| try { | |
| arriving = sessionStorage.getItem('parlor:arrival') === '1'; | |
| if (arriving) sessionStorage.removeItem('parlor:arrival'); | |
| } catch (_) { /* storage may be disabled */ } | |
| function revealContent() { | |
| if (!gsap || reducedMotion) return; | |
| document.documentElement.classList.add('gsap-ready'); | |
| gsap.timeline({ defaults: { ease: 'power2.out' } }) | |
| .fromTo('.room-heading', { y: 16, autoAlpha: 0 }, { y: 0, autoAlpha: 1, duration: 0.48 }, 0) | |
| .fromTo('.gameplay-panel', { y: 22, autoAlpha: 0 }, { y: 0, autoAlpha: 1, duration: 0.58 }, 0.08) | |
| .fromTo('.room-main .chat', { y: 14, autoAlpha: 0 }, { y: 0, autoAlpha: 1, duration: 0.48 }, 0.18) | |
| .fromTo('.rail .panel', { x: -12, autoAlpha: 0 }, { x: 0, autoAlpha: 1, duration: 0.4, stagger: 0.08 }, 0.12); | |
| } | |
| if (!arriving) { | |
| revealContent(); | |
| return; | |
| } | |
| if (!showScene('THE MIDNIGHT PARLOR', 'The room has noticed you.')) return; | |
| if (!gsap || reducedMotion) { | |
| overlay.classList.add('is-active', 'is-closed'); | |
| requestAnimationFrame(function () { overlay.classList.add('is-opening'); }); | |
| window.setTimeout(function () { hideScene(); revealContent(); }, reducedMotion ? 80 : 760); | |
| return; | |
| } | |
| gsap.set(overlay, { autoAlpha: 1 }); | |
| gsap.set(leftDoor, { xPercent: 0 }); | |
| gsap.set(rightDoor, { xPercent: 0 }); | |
| gsap.set(core, { autoAlpha: 1, y: 0, scale: 1 }); | |
| gsap.timeline({ defaults: { ease: 'power3.inOut' }, onComplete: function () { | |
| hideScene(); | |
| revealContent(); | |
| } }) | |
| .to(leftDoor, { xPercent: -100, duration: 0.86 }, 0.2) | |
| .to(rightDoor, { xPercent: 100, duration: 0.86 }, 0.2) | |
| .to(core, { autoAlpha: 0, y: -8, duration: 0.24 }, 0) | |
| .to('.scene-rule', { scaleX: 0, duration: 0.36 }, 0.05); | |
| } | |
| function openOnboarding() { | |
| const card = document.querySelector('.onboarding-card'); | |
| if (!card) return; | |
| if (gsap && !reducedMotion) { | |
| gsap.fromTo(card, { y: 26, scale: 0.97, autoAlpha: 0 }, { | |
| y: 0, scale: 1, autoAlpha: 1, duration: 0.62, ease: 'power3.out', clearProps: 'transform', | |
| }); | |
| } else { | |
| card.classList.add('is-entered'); | |
| } | |
| } | |
| function closeOnboarding(onComplete) { | |
| const modal = document.getElementById('onboarding-overlay'); | |
| const card = document.querySelector('.onboarding-card'); | |
| if (!modal) { if (onComplete) onComplete(); return; } | |
| const finish = function () { | |
| modal.hidden = true; | |
| modal.setAttribute('aria-hidden', 'true'); | |
| document.body.classList.remove('onboarding-active'); | |
| if (onComplete) onComplete(); | |
| }; | |
| if (gsap && !reducedMotion && card) { | |
| gsap.timeline({ onComplete: finish }) | |
| .to(card, { y: 10, autoAlpha: 0, duration: 0.24, ease: 'power2.in' }) | |
| .to(modal, { autoAlpha: 0, duration: 0.22 }, '<0.04'); | |
| } else { | |
| modal.classList.add('is-closing'); | |
| window.setTimeout(finish, reducedMotion ? 0 : 220); | |
| } | |
| } | |
| function animateLobby() { | |
| const hero = document.querySelector('.hero'); | |
| if (!hero) return; | |
| if (gsap && !reducedMotion) { | |
| document.documentElement.classList.add('gsap-ready'); | |
| gsap.timeline({ defaults: { ease: 'power3.out' } }) | |
| .from('.hero .eyebrow', { y: 12, autoAlpha: 0, duration: 0.42 }) | |
| .from('.hero h1', { y: 24, autoAlpha: 0, duration: 0.64 }, '<0.06') | |
| .from('.hero .lede', { y: 12, autoAlpha: 0, duration: 0.5 }, '<0.1') | |
| .from('.hero + .grid > .panel', { y: 22, autoAlpha: 0, duration: 0.55, stagger: 0.12 }, '<0.1'); | |
| } | |
| } | |
| window.ParlorMotion = { enterRoom: enterRoom, revealRoom: revealRoom, openOnboarding: openOnboarding, closeOnboarding: closeOnboarding }; | |
| animateLobby(); | |
| revealRoom(); | |
| })(); | |