feat: Zeitleiste als Scroll-Kamerafahrt nach mesh3d-Vorbild
Einträge starten tief im Raum (translateZ) und fahren beim Scrollen kontinuierlich auf den Betrachter zu – gekoppelt an die Scrollposition statt einmaliger Feder-Animation. Mobile mit geringerer Tiefe, Startzustand wird sofort gesetzt. Tilt und Fallback-Pfad bleiben unverändert.
This commit is contained in:
1 parent
1dec02e37a
commit
1d3624cdc0
1 file changed
+62
-52
+62
-52
@@ -1,10 +1,11 @@
|
|||||||
/* zeitlinie.js – Animationen für die Saison-Rückblick-Zeitleiste:
|
/* zeitlinie.js – Animationen für die Saison-Rückblick-Zeitleiste:
|
||||||
1) Eintritt der Einträge (3D-Schwenk von unten)
|
1) Tauch-Fahrt: Einträge starten tief im Raum und kommen beim
|
||||||
|
Scrollen auf den Betrachter zu (an den Scroll gekoppelt,
|
||||||
|
wie eine Kamerafahrt durch den Saison-Speicher)
|
||||||
2) Goldene Fortschritts-Achse beim Scrollen
|
2) Goldene Fortschritts-Achse beim Scrollen
|
||||||
3) Dezenten 3D-Tilt der Karten bei Mausbewegung (nur Desktop-Zeiger)
|
3) Dezenter 3D-Tilt der Karten bei Mausbewegung (nur Desktop-Zeiger)
|
||||||
Mit Motion (bewegung.js-Ladereihe) federn die Einträge und hängt die
|
Mit Motion läuft 1)+2) als Scroll-Scrubbing; ohne Motion gilt das
|
||||||
Achse direkt am Scroll – ohne Motion gilt das einfache System.
|
einfache Einblenden-System. Respektiert prefers-reduced-motion. */
|
||||||
Respektiert prefers-reduced-motion. */
|
|
||||||
(function () {
|
(function () {
|
||||||
"use strict";
|
"use strict";
|
||||||
var reduce = window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
var reduce = window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
||||||
@@ -12,63 +13,72 @@
|
|||||||
var liste = document.querySelector(".zeitliste");
|
var liste = document.querySelector(".zeitliste");
|
||||||
if (!liste) return;
|
if (!liste) return;
|
||||||
var punkte = Array.prototype.slice.call(liste.querySelectorAll(".zeit-punkt"));
|
var punkte = Array.prototype.slice.call(liste.querySelectorAll(".zeit-punkt"));
|
||||||
var mitMotion = !!(M && typeof M.animate === "function") && !reduce;
|
var mitMotion = !!(M && typeof M.animate === "function" &&
|
||||||
|
typeof M.scroll === "function") && !reduce;
|
||||||
|
|
||||||
/* ---------- 1) Einträge einfliegen lassen ---------- */
|
|
||||||
if (mitMotion) {
|
if (mitMotion) {
|
||||||
|
|
||||||
|
/* ---------- 1)+2) Kamerafahrt + Achse, beide am Scroll ---------- */
|
||||||
|
var mobil = window.matchMedia("(max-width: 859.98px)");
|
||||||
|
var tiefe = function () { return mobil.matches ? 520 : 900; };
|
||||||
|
|
||||||
|
function zustand(punkt, f) {
|
||||||
|
/* f = 0: ganz hinten im Raum · f = 1: angekommen */
|
||||||
|
var rest = 1 - f;
|
||||||
|
punkt.style.opacity = String(Math.min(1, f / 0.4));
|
||||||
|
punkt.style.transform =
|
||||||
|
"translateZ(" + (-rest * tiefe()).toFixed(1) + "px)" +
|
||||||
|
" rotateX(" + (rest * 6).toFixed(2) + "deg)";
|
||||||
|
}
|
||||||
|
|
||||||
punkte.forEach(function (punkt) {
|
punkte.forEach(function (punkt) {
|
||||||
punkt.style.transition = "none";
|
punkt.style.transition = "none";
|
||||||
punkt.style.opacity = "0";
|
punkt.style.willChange = "transform, opacity";
|
||||||
punkt.style.transform =
|
zustand(punkt, 0);
|
||||||
"rotateX(12deg) translateY(46px) scale(0.97)";
|
|
||||||
M.inView(
|
|
||||||
punkt,
|
|
||||||
function () {
|
|
||||||
if (punkt.dataset.bewegungFertig) return;
|
|
||||||
punkt.dataset.bewegungFertig = "1";
|
|
||||||
M.animate(
|
|
||||||
punkt,
|
|
||||||
{
|
|
||||||
opacity: [0, 1],
|
|
||||||
transform: [
|
|
||||||
"rotateX(12deg) translateY(46px) scale(0.97)",
|
|
||||||
"rotateX(0deg) translateY(0px) scale(1)"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{ type: "spring", stiffness: 170, damping: 24 }
|
|
||||||
);
|
|
||||||
},
|
|
||||||
{ amount: 0.18 }
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
} else if (punkte.length && "IntersectionObserver" in window && !reduce) {
|
|
||||||
var beobachter = new IntersectionObserver(function (eintraege) {
|
|
||||||
eintraege.forEach(function (eintrag) {
|
|
||||||
if (eintrag.isIntersecting) {
|
|
||||||
eintrag.target.classList.add("sichtbar");
|
|
||||||
beobachter.unobserve(eintrag.target);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}, { threshold: 0.15, rootMargin: "0px 0px -40px 0px" });
|
|
||||||
punkte.forEach(function (el) { beobachter.observe(el); });
|
|
||||||
} else {
|
|
||||||
punkte.forEach(function (el) { el.classList.add("sichtbar"); });
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ---------- 2) Fortschritt der Achse ----------
|
var fahren = function () {
|
||||||
Mit Motion direkt an den Scroll gekoppelt (weich scrubbing),
|
var kante = window.innerHeight;
|
||||||
sonst über einen entprellten Scroll-Handler. */
|
var beginn = kante * 0.97; /* Eintritt unten im Fenster */
|
||||||
if (!reduce) {
|
var ende = kante * 0.46; /* Ruheposition erreicht */
|
||||||
var aktualisieren = function () {
|
for (var i = 0; i < punkte.length; i++) {
|
||||||
|
var oben = punkte[i].getBoundingClientRect().top;
|
||||||
|
var f = (beginn - oben) / (beginn - ende);
|
||||||
|
f = Math.min(1, Math.max(0, f));
|
||||||
|
zustand(punkte[i], f);
|
||||||
|
}
|
||||||
var r = liste.getBoundingClientRect();
|
var r = liste.getBoundingClientRect();
|
||||||
var anteil = (window.innerHeight * 0.7 - r.top) / r.height;
|
var achse = (kante * 0.7 - r.top) / r.height;
|
||||||
anteil = Math.min(1, Math.max(0, anteil));
|
achse = Math.min(1, Math.max(0, achse));
|
||||||
liste.style.setProperty("--fortschritt", (anteil * 100).toFixed(2) + "%");
|
liste.style.setProperty("--fortschritt", (achse * 100).toFixed(2) + "%");
|
||||||
};
|
};
|
||||||
if (mitMotion && typeof M.scroll === "function") {
|
fahren(); /* Startzustand sofort herstellen … */
|
||||||
M.scroll(aktualisieren);
|
M.scroll(fahren); /* … und danach an den Scroll koppeln */
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
/* ---------- Fallback: sanftes Einblenden wie bisher ---------- */
|
||||||
|
if (punkte.length && "IntersectionObserver" in window && !reduce) {
|
||||||
|
var beobachter = new IntersectionObserver(function (eintraege) {
|
||||||
|
eintraege.forEach(function (eintrag) {
|
||||||
|
if (eintrag.isIntersecting) {
|
||||||
|
eintrag.target.classList.add("sichtbar");
|
||||||
|
beobachter.unobserve(eintrag.target);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}, { threshold: 0.15, rootMargin: "0px 0px -40px 0px" });
|
||||||
|
punkte.forEach(function (el) { beobachter.observe(el); });
|
||||||
} else {
|
} else {
|
||||||
|
punkte.forEach(function (el) { el.classList.add("sichtbar"); });
|
||||||
|
}
|
||||||
|
if (!reduce) {
|
||||||
var wartend = false;
|
var wartend = false;
|
||||||
|
var aktualisieren = function () {
|
||||||
|
var r = liste.getBoundingClientRect();
|
||||||
|
var anteil = (window.innerHeight * 0.7 - r.top) / r.height;
|
||||||
|
anteil = Math.min(1, Math.max(0, anteil));
|
||||||
|
liste.style.setProperty("--fortschritt", (anteil * 100).toFixed(2) + "%");
|
||||||
|
};
|
||||||
window.addEventListener("scroll", function () {
|
window.addEventListener("scroll", function () {
|
||||||
if (!wartend) {
|
if (!wartend) {
|
||||||
wartend = true;
|
wartend = true;
|
||||||
|
|||||||
Reference in new issue
Block a user