feat: Motion-Basisschicht für alle Seiten
motion.dev (selbst gehostet, wie lenis/confetti) als zentrale Bewegungsschicht: Scroll-Reveals federn jetzt mit leichtem Nachschwingen und staffeln sich pro Galerie, Unterseiten-Helden laufen versetzt ein, Buttons federn beim Drücken. bewegung.js übernimmt die .einblenden-Logik vor transitions.js; ohne Motion oder bei reduzierter Bewegung gilt unverändert das alte System. Zusätzlich noscript-Style, damit Inhalte ohne JavaScript sichtbar bleiben.
This commit is contained in:
1 parent
e68fdf88a3
commit
058b1004c2
32 files changed
+208
-30
No files matched your search
@@ -0,0 +1,111 @@
|
||||
/* bewegung.js – zentrale Bewegungsschicht mit Motion (motion.dev) für ALLE Seiten.
|
||||
Federn statt Linearität: Scroll-Reveals, Hero-Auftakt, Button-Druck.
|
||||
Dosiert nach docs/style-tokens.md – weiß, ruhig, leichtes Nachschwingen.
|
||||
Regeln:
|
||||
· Ohne Motion oder bei prefers-reduced-motion: gar nichts tun,
|
||||
das bestehende System (transitions.js) übernimmt unverändert.
|
||||
· Ohne JavaScript bleibt alles sichtbar (noscript-Style in jeder Seite).
|
||||
· Inhalte stehen statisch im HTML – Animation ist reine Veredelung (SEO-sicher). */
|
||||
(function () {
|
||||
"use strict";
|
||||
var M = window.Motion;
|
||||
if (!M || typeof M.animate !== "function") return;
|
||||
if (window.matchMedia("(prefers-reduced-motion: reduce)").matches) return;
|
||||
|
||||
/* ---------- 1) Scroll-Reveals: .einblenden übernehmen ----------
|
||||
Klasse entfernen (verhindert den alten CSS-Übergang aus transitions.js)
|
||||
und den Anfangszustand sofort setzen, bevor der Browser malt. */
|
||||
var elemente = Array.prototype.slice.call(
|
||||
document.querySelectorAll(".einblenden")
|
||||
);
|
||||
|
||||
function verstecken(el) {
|
||||
el.classList.remove("einblenden");
|
||||
el.style.opacity = "0";
|
||||
el.style.transform = "translateY(22px)";
|
||||
}
|
||||
|
||||
function zeigen(els, abstand) {
|
||||
M.animate(
|
||||
els,
|
||||
{ opacity: [0, 1], transform: ["translateY(22px)", "translateY(0px)"] },
|
||||
{ type: "spring", stiffness: 190, damping: 26, delay: M.stagger(abstand) }
|
||||
);
|
||||
}
|
||||
|
||||
if (elemente.length) {
|
||||
/* Nach Containern gruppieren: Kinder einer Galerie federn gestaffelt,
|
||||
Elemente ohne Container einzeln für sich. */
|
||||
var gruppen = [];
|
||||
var zuordnung = new Map();
|
||||
elemente.forEach(function (el) {
|
||||
var container =
|
||||
el.closest(".auszug-grid, .galerie-spalten, .bento-grid") || el;
|
||||
if (!zuordnung.has(container)) {
|
||||
zuordnung.set(container, []);
|
||||
gruppen.push(container);
|
||||
}
|
||||
zuordnung.get(container).push(el);
|
||||
});
|
||||
|
||||
gruppen.forEach(function (container) {
|
||||
var kinder = zuordnung.get(container);
|
||||
kinder.forEach(verstecken);
|
||||
M.inView(
|
||||
container,
|
||||
function () {
|
||||
var frische = kinder.filter(function (el) {
|
||||
return !el.dataset.bewegungGestartet;
|
||||
});
|
||||
if (!frische.length) return;
|
||||
frische.forEach(function (el) {
|
||||
el.dataset.bewegungGestartet = "1";
|
||||
/* Klasse für reine CSS-Kinder-Effekte (z. B. Polaroid-Fächer) */
|
||||
el.classList.add("sichtbar");
|
||||
});
|
||||
zeigen(frische, 0.07);
|
||||
},
|
||||
{ amount: container === kinder[0] ? 0.15 : 0.12 }
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
/* ---------- 2) Hero-Auftakt auf Unterseiten ---------- */
|
||||
var hero = document.querySelector(".page-hero");
|
||||
if (hero) {
|
||||
var teile = [].slice.call(
|
||||
hero.querySelectorAll(".hero-label, .hero-title, .hero-sub, .chronik-verweis")
|
||||
);
|
||||
if (teile.length) {
|
||||
teile.forEach(function (el) {
|
||||
el.style.opacity = "0";
|
||||
el.style.transform = "translateY(16px)";
|
||||
});
|
||||
M.animate(
|
||||
teile,
|
||||
{ opacity: [0, 1], transform: ["translateY(16px)", "translateY(0px)"] },
|
||||
{
|
||||
type: "spring", stiffness: 210, damping: 30,
|
||||
delay: M.stagger(0.08, { startDelay: 0.05 })
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/* ---------- 3) Button-Druck (Mikro-Feder) ---------- */
|
||||
Array.prototype.slice.call(document.querySelectorAll(".button")).forEach(
|
||||
function (button) {
|
||||
button.addEventListener("pointerdown", function () {
|
||||
M.animate(button, { scale: 0.96 },
|
||||
{ type: "spring", stiffness: 500, damping: 28 });
|
||||
});
|
||||
var loslassen = function () {
|
||||
M.animate(button, { scale: 1 },
|
||||
{ type: "spring", stiffness: 380, damping: 22 });
|
||||
};
|
||||
button.addEventListener("pointerup", loslassen);
|
||||
button.addEventListener("pointercancel", loslassen);
|
||||
button.addEventListener("pointerleave", loslassen);
|
||||
}
|
||||
);
|
||||
})();
|
||||
Vendored
+7
@@ -0,0 +1,7 @@
|
||||
/**
|
||||
* Skipped minification because the original files appears to be already minified.
|
||||
* Original file: /npm/motion@12.43.0/dist/motion.js
|
||||
*
|
||||
* Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
|
||||
*/
|
||||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).Motion={})}(this,function(t){"use strict";function e(t,e){-1===t.indexOf(e)&&t.push(e)}function n(t,e){const n=t.indexOf(e);n>-1&&t.splice(n,1)}const i=(t,e,n)=>n>e?e:n<t?t:n;function s(t,e){return e?`${t}. For more information and steps for solving, visit https://motion.dev/troubleshooting/${e}`:t}t.warning=()=>{},t.invariant=()=>{},"undefined"!=typeof process&&"production"!==process.env?.NODE_ENV&&(t.warning=(t,e,n)=>{t||"undefined"==typeof console||console.warn(s(e,n))},t.invariant=(t,e,n)=>{if(!t)throw new Error(s(e,n))});const o={},r=t=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(t),a=t=>"object"==typeof t&&null!==t,l=t=>/^0[^.\s]+$/u.test(t);function c(t){let e;return()=>(void 0===e&&(e=t()),e)}const u=t=>t,h=(...t)=>t.reduce((t,e)=>n=>e(t(n))),d=(t,e,n)=>{const i=e-t;return i?(n-t)/i:1};class p{constructor(){this.subscriptions=[]}add(t){return e(this.subscriptions,t),()=>n(this.subscriptions,t)}notify(t,e,n){const i=this.subscriptions.length;if(i)if(1===i)this.subscriptions[0](t,e,n);else for(let s=0;s<i;s++){const i=this.subscriptions[s];i&&i(t,e,n)}}getSize(){return this.subscriptions.length}clear(){this.subscriptions.length=0}}const m=t=>1e3*t,f=t=>t/1e3,y=(t,e)=>e?t*(1e3/e):0,g=new Set;function v(t,e,n){t||g.has(e)||(console.warn(s(e,n)),g.add(e))}const x=(t,e,n)=>{const i=e-t;return((n-t)%i+i)%i+t},w=(t,e,n)=>(((1-3*n+3*e)*t+(3*n-6*e))*t+3*e)*t;function T(t,e,n,i){if(t===e&&n===i)return u;const s=e=>function(t,e,n,i,s){let o,r,a=0;do{r=e+(n-e)/2,o=w(r,i,s)-t,o>0?n=r:e=r}while(Math.abs(o)>1e-7&&++a<12);return r}(e,0,1,t,n);return t=>0===t||1===t?t:w(s(t),e,i)}const b=t=>e=>e<=.5?t(2*e)/2:(2-t(2*(1-e)))/2,S=t=>e=>1-t(1-e),A=T(.33,1.53,.69,.99),V=S(A),P=b(V),M=t=>t>=1?1:(t*=2)<1?.5*V(t):.5*(2-Math.pow(2,-10*(t-1))),E=t=>1-Math.sin(Math.acos(t)),k=S(E),D=b(E),C=T(.42,0,1,1),B=T(0,0,.58,1),R=T(.42,0,.58,1);const L=t=>Array.isArray(t)&&"number"!=typeof t[0];function j(t,e){return L(t)?t[x(0,t.length,e)]:t}const O=t=>Array.isArray(t)&&"number"==typeof t[0],F={linear:u,easeIn:C,easeInOut:R,easeOut:B,circIn:E,circInOut:D,circOut:k,backIn:V,backInOut:P,backOut:A,anticipate:M},I=e=>{if(O(e)){t.invariant(4===e.length,"Cubic bezier arrays must contain four numerical values.","cubic-bezier-length");const[n,i,s,o]=e;return T(n,i,s,o)}return"string"==typeof e?(t.invariant(void 0!==F[e],`Invalid easing type '${e}'`,"invalid-easing-type"),F[e]):e},$=["setup","read","resolveKeyframes","preUpdate","update","preRender","render","postRender"];function N(t,e){let n=!1,i=!0;const s={delta:0,timestamp:0,isProcessing:!1},r=()=>n=!0,a=$.reduce((t,e)=>(t[e]=function(t){let e=new Set,n=new Set,i=!1,s=!1;const o=new WeakSet;let r={delta:0,timestamp:0,isProcessing:!1};function a(e){o.has(e)&&(l.schedule(e),t()),e(r)}const l={schedule:(t,s=!1,r=!1)=>{const a=r&&i?e:n;return s&&o.add(t),a.add(t),t},cancel:t=>{n.delete(t),o.delete(t)},process:t=>{if(r=t,i)return void(s=!0);i=!0;const o=e;e=n,n=o,e.forEach(a),e.clear(),i=!1,s&&(s=!1,l.process(t))}};return l}(r),t),{}),{setup:l,read:c,resolveKeyframes:u,preUpdate:h,update:d,preRender:p,render:m,postRender:f}=a,y=()=>{const r=o.useManualTiming,a=r?s.timestamp:performance.now();n=!1,r||(s.delta=i?1e3/60:Math.max(Math.min(a-s.timestamp,40),1)),s.timestamp=a,s.isProcessing=!0,l.process(s),c.process(s),u.process(s),h.process(s),d.process(s),p.process(s),m.process(s),f.process(s),s.isProcessing=!1,n&&e&&(i=!1,t(y))};return{schedule:$.reduce((e,o)=>{const r=a[o];return e[o]=(e,o=!1,a=!1)=>(n||(n=!0,i=!0,s.isProcessing||t(y)),r.schedule(e,o,a)),e},{}),cancel:t=>{for(let e=0;e<$.length;e++)a[$[e]].cancel(t)},state:s,steps:a}}const{schedule:W,cancel:U,state:z,steps:K}=N("undefined"!=typeof requestAnimationFrame?requestAnimationFrame:u,!0);let Y;function X(){Y=void 0}const G={now:()=>(void 0===Y&&G.set(z.isProcessing||o.useManualTiming?z.timestamp:performance.now()),Y),set:t=>{Y=t,queueMicrotask(X)}},H=t=>e=>"string"==typeof e&&e.startsWith(t),q=H("--"),Z=H("var(--"),_=t=>!!Z(t)&&J.test(t.split("/*")[0].trim()),J=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu;function Q(t){return"string"==typeof t&&t.split("/*")[0].includes("var(--")}const tt={test:t=>"number"==typeof t,parse:parseFloat,transform:t=>t},et={...tt,transform:t=>i(0,1,t)},nt={...tt,default:1},it=t=>Math.round(1e5*t)/1e5,st=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;const ot=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,rt=(t,e)=>n=>Boolean("string"==typeof n&&ot.test(n)&&n.startsWith(t)||e&&!function(t){return null==t}(n)&&Object.prototype.hasOwnProperty.call(n,e)),at=(t,e,n)=>i=>{if("string"!=typeof i)return i;const[s,o,r,a]=i.match(st);return{[t]:parseFloat(s),[e]:parseFloat(o),[n]:parseFloat(r),alpha:void 0!==a?parseFloat(a):1}},lt={...tt,transfLine truncated
|
||||
Reference in new issue
Block a user