Files
portfolio-photo/public/custom/fokus.js
T
Leon TonhäuserandClaude f1b140d65a feat: Intro „Fokus" (Schärfeverlagerung) ersetzt Tiefenflug
- Scroll-basiertes Intro: Held-Bild zieht in die Schärfe, Scrollen wechselt
  eine 5-Bild-Serie (Schärfeverlagerung), monochromes HUD mit Belichtungs-
  daten/Bildunterschrift, Fortschrittslinie, Fokus-Klammern.
- fokus.css/fokus.js neu; LANDUNG-Block 1:1 aus tiefenflug.css übernommen.
- Klasse .flug-strecke erhalten (transitions.js erkennt Intro weiterhin).
- tiefenflug.css/tiefenflug.js entfernt, canvas-confetti-Scripttag raus.
- Fallbacks: .kein-js und prefers-reduced-motion blenden Intro aus.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-06-23 22:40:09 +02:00

105 lines
4.6 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// Steuert das Intro „Fokus" auf index.html (ersetzt „Tiefenflug").
//
// Prinzip: Die Seite hat oben eine hohe Scroll-Strecke (#flug-strecke) mit
// festgehefteter (sticky) Bühne. Der Scroll-Fortschritt (0..1) zieht nach-
// einander die besten Bilder in die Schärfe (Schärfeverlagerung wie an einer
// Profikamera): unscharf + leicht vergrößert hinein, dann sauber scharf.
// Belichtungsdaten und Bildunterschrift wechseln mit. Am Ende blendet die
// HUD-Schicht aus und die Strecke gibt die normale Startseite frei.
//
// Werte/Charakter an docs/style-tokens.md ausgerichtet (Einblenden ~0.4 s,
// große Auftritte mit „ease-out": schnell rein, weich ankommen).
(function () {
'use strict';
// JS läuft → Fallback-Klasse entfernen (CSS blendet das Intro sonst aus)
document.documentElement.classList.remove('kein-js');
var strecke = document.getElementById('flug-strecke');
if (!strecke) return;
// Reduzierte Bewegung: Intro überspringen, normale Seite direkt zeigen
if (window.matchMedia('(prefers-reduced-motion: reduce)').matches) {
document.documentElement.classList.add('ohne-intro');
return;
}
var bild = document.getElementById('fokus-bild');
var wrap = document.getElementById('fokus-bildwrap');
var hud = document.getElementById('fokus-hud');
var expo = document.getElementById('fokus-expo');
var cap = document.getElementById('fokus-cap');
var hinweis = document.getElementById('fokus-hinweis');
var bar = document.getElementById('fokus-bar');
// Bildserie des Intros. Leon tauscht später nur die Dateinamen + Texte –
// die Animation läuft unverändert weiter.
var BILDER = [
{ src: 'assets/images_0i8JnT02uuSvPhFfGu3HEuR9iw.jpg', cap: 'RANSFORD KÖNIGSDÖRFFER · HSV · 1. BUNDESLIGA', ex: '1/2000s · f/2.8 · ISO800 · 400mm' },
{ src: 'assets/images_HNzZXNv3swzd9BBXglhXh2VaIH4.jpg', cap: 'SLAM DUNK · WORLD UNIVERSITY GAMES', ex: '1/1600s · f/2.8 · ISO1600 · 200mm' },
{ src: 'assets/images_MZkgUjHC5X95ogvnQ76W0pUGgo.jpg', cap: 'CHOREO · VOLKSPARKSTADION · HAMBURGER SV', ex: '1/500s · f/4.0 · ISO3200 · 24mm' },
{ src: 'assets/images_28CetpAPO7FEloGfrxtGfC2LSIU.jpg', cap: 'TORJUBEL · FRAUEN-BUNDESLIGA', ex: '1/1250s · f/2.8 · ISO2000 · 135mm' },
{ src: 'assets/images_47wplBRD0TcqxkplziaIdw5IJT8.jpg', cap: 'FANKURVE · AUSWÄRTSSUPPORT', ex: '1/640s · f/2.8 · ISO2500 · 35mm' }
];
var BLUR = 16; // px Unschärfe am Anfang der Schärfeverlagerung
var BILD_ENDE = 0.85; // Anteil der Strecke, über den die Bilder laufen (Rest: HUD-Ausblendung)
var aktuell = -1; // aktuell scharfgestelltes Bild
var ticking = false;
function maxScroll() {
return strecke.offsetHeight - window.innerHeight;
}
// Ein Bild in die Schärfe ziehen: unscharf/vergrößert setzen, dann weich scharf.
function scharfstellen(i) {
var b = BILDER[i];
if (!b || !bild) return;
bild.style.transition = 'none';
bild.style.filter = 'blur(' + BLUR + 'px)';
bild.style.transform = 'scale(1.06)';
bild.style.opacity = '0.45';
void bild.offsetWidth; // Reflow erzwingen, damit der Startzustand „sitzt"
bild.src = b.src;
bild.style.transition = 'filter 1.3s cubic-bezier(0.16, 1, 0.3, 1), transform 1.3s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.65s ease-out';
bild.style.filter = 'blur(0px)';
bild.style.transform = 'scale(1)';
bild.style.opacity = '1';
if (expo) expo.textContent = b.ex;
if (cap) cap.textContent = b.cap;
}
function zeichnen() {
var p = Math.min(Math.max(window.scrollY / maxScroll(), 0), 1);
if (bar) bar.style.width = (p * 100).toFixed(2) + '%';
if (hinweis) hinweis.style.opacity = p > 0.03 ? '0' : '';
// HUD blendet auf den letzten 10 % weich aus → sauberer Übergang in die Seite
if (hud) hud.style.opacity = p < 0.9 ? '1' : String(Math.max(0, 1 - (p - 0.9) / 0.1));
var pBild = Math.min(p / BILD_ENDE, 1);
var idx = Math.min(Math.floor(pBild * BILDER.length), BILDER.length - 1);
var teil = pBild * BILDER.length - idx; // 0..1 innerhalb des aktuellen Bildes
// Dezente Eigenbewegung des scharfen Bildes (langsamer „Ken Burns")
if (wrap) {
wrap.style.transform = 'scale(' + (1 + teil * 0.05).toFixed(4) + ') translateY(' + (teil * -2).toFixed(2) + '%)';
}
if (idx !== aktuell) { aktuell = idx; scharfstellen(idx); }
}
window.addEventListener('scroll', function () {
if (ticking) return;
ticking = true;
requestAnimationFrame(function () { zeichnen(); ticking = false; });
}, { passive: true });
window.addEventListener('resize', zeichnen);
// Erststart: erstes Bild beim Laden scharfziehen, dann Stand zeichnen
aktuell = 0;
scharfstellen(0);
zeichnen();
})();