@skerbis/nativecss 0.0.0-stage → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (192) hide show
  1. package/CHANGELOG.md +38 -0
  2. package/LICENSE +28 -0
  3. package/README.md +144 -2
  4. package/dist/base.css +225 -0
  5. package/dist/browser-fixes.css +32 -0
  6. package/dist/colors.css +288 -0
  7. package/dist/components/accordion-split.css +269 -0
  8. package/dist/components/alert.css +179 -0
  9. package/dist/components/app-shell.css +266 -0
  10. package/dist/components/audio-player.css +697 -0
  11. package/dist/components/audio.css +35 -0
  12. package/dist/components/aurora.css +132 -0
  13. package/dist/components/avatar.css +102 -0
  14. package/dist/components/back-to-top.css +120 -0
  15. package/dist/components/backdrop.css +94 -0
  16. package/dist/components/badge.css +95 -0
  17. package/dist/components/breadcrumb.css +58 -0
  18. package/dist/components/card.css +721 -0
  19. package/dist/components/code-block.css +234 -0
  20. package/dist/components/combobox.css +103 -0
  21. package/dist/components/command-palette.css +351 -0
  22. package/dist/components/comments.css +243 -0
  23. package/dist/components/compare.css +218 -0
  24. package/dist/components/count-up.css +140 -0
  25. package/dist/components/countdown.css +74 -0
  26. package/dist/components/cover.css +45 -0
  27. package/dist/components/curtain.css +116 -0
  28. package/dist/components/dialog-close.css +44 -0
  29. package/dist/components/disclosure.css +37 -0
  30. package/dist/components/downloads.css +47 -0
  31. package/dist/components/dropdown.css +260 -0
  32. package/dist/components/dropzone.css +181 -0
  33. package/dist/components/effects.css +236 -0
  34. package/dist/components/empty-state.css +74 -0
  35. package/dist/components/events.css +165 -0
  36. package/dist/components/expand-panels.css +220 -0
  37. package/dist/components/filter.css +179 -0
  38. package/dist/components/floating-label.css +69 -0
  39. package/dist/components/footer.css +56 -0
  40. package/dist/components/hero.css +139 -0
  41. package/dist/components/hovercard.css +146 -0
  42. package/dist/components/input-group.css +67 -0
  43. package/dist/components/kbd.css +44 -0
  44. package/dist/components/leaders.css +99 -0
  45. package/dist/components/lightbox.css +165 -0
  46. package/dist/components/lists.css +221 -0
  47. package/dist/components/livesearch.css +106 -0
  48. package/dist/components/map.css +245 -0
  49. package/dist/components/marginnote.css +109 -0
  50. package/dist/components/marquee.css +119 -0
  51. package/dist/components/modal.css +385 -0
  52. package/dist/components/morph.css +317 -0
  53. package/dist/components/nav-drilldown.css +190 -0
  54. package/dist/components/nav-priority.css +157 -0
  55. package/dist/components/nav.css +528 -0
  56. package/dist/components/notification.css +290 -0
  57. package/dist/components/off-canvas.css +107 -0
  58. package/dist/components/overlay.css +122 -0
  59. package/dist/components/pagination.css +139 -0
  60. package/dist/components/pill-group.css +143 -0
  61. package/dist/components/placeholder.css +28 -0
  62. package/dist/components/preferences-fonts.css +65 -0
  63. package/dist/components/preferences.css +283 -0
  64. package/dist/components/pricing.css +220 -0
  65. package/dist/components/rating.css +121 -0
  66. package/dist/components/reveal-pin.css +165 -0
  67. package/dist/components/roadmap.css +173 -0
  68. package/dist/components/scroll-frames.css +97 -0
  69. package/dist/components/scroll-horizontal.css +141 -0
  70. package/dist/components/scroll-progress.css +63 -0
  71. package/dist/components/scroll-stack.css +363 -0
  72. package/dist/components/scroll-video.css +172 -0
  73. package/dist/components/scrolly.css +190 -0
  74. package/dist/components/search.css +52 -0
  75. package/dist/components/segmented.css +209 -0
  76. package/dist/components/select.css +186 -0
  77. package/dist/components/slideshow.css +441 -0
  78. package/dist/components/sortable.css +186 -0
  79. package/dist/components/sparkline.css +50 -0
  80. package/dist/components/spinner.css +50 -0
  81. package/dist/components/split.css +85 -0
  82. package/dist/components/spotlight.css +111 -0
  83. package/dist/components/stat.css +82 -0
  84. package/dist/components/stepper.css +217 -0
  85. package/dist/components/subnav.css +151 -0
  86. package/dist/components/table-sort.css +111 -0
  87. package/dist/components/tabs.css +304 -0
  88. package/dist/components/tag.css +130 -0
  89. package/dist/components/testimonial.css +188 -0
  90. package/dist/components/text-reveal.css +141 -0
  91. package/dist/components/theme-toggle.css +62 -0
  92. package/dist/components/tile.css +53 -0
  93. package/dist/components/timeline.css +211 -0
  94. package/dist/components/toolbar.css +139 -0
  95. package/dist/components/tooltip.css +89 -0
  96. package/dist/components/topbar.css +92 -0
  97. package/dist/components/video-bg.css +176 -0
  98. package/dist/components/video-card.css +145 -0
  99. package/dist/components/video-float.css +142 -0
  100. package/dist/components/video-player.css +1116 -0
  101. package/dist/components/video-text.css +91 -0
  102. package/dist/components/video.css +65 -0
  103. package/dist/fonts/README.md +29 -0
  104. package/dist/fonts/atkinson-hyperlegible-next/OFL.txt +93 -0
  105. package/dist/fonts/atkinson-hyperlegible-next/atkinson-hyperlegible-next.woff2 +0 -0
  106. package/dist/fonts/lexend/OFL.txt +93 -0
  107. package/dist/fonts/lexend/lexend.woff2 +0 -0
  108. package/dist/fonts/opendyslexic/OFL.txt +94 -0
  109. package/dist/fonts/opendyslexic/OpenDyslexic-Bold.woff2 +0 -0
  110. package/dist/fonts/opendyslexic/OpenDyslexic-Regular.woff2 +0 -0
  111. package/dist/helpers/a11y.css +71 -0
  112. package/dist/helpers/animations.css +206 -0
  113. package/dist/helpers/elevation.css +87 -0
  114. package/dist/helpers/float.css +117 -0
  115. package/dist/helpers/forms.css +503 -0
  116. package/dist/helpers/icons.css +130 -0
  117. package/dist/helpers/layout.css +549 -0
  118. package/dist/helpers/media.css +77 -0
  119. package/dist/helpers/reveal.css +172 -0
  120. package/dist/helpers/scroll-shadow.css +129 -0
  121. package/dist/helpers/scroll.css +163 -0
  122. package/dist/helpers/surfaces.css +87 -0
  123. package/dist/helpers/tables.css +85 -0
  124. package/dist/helpers/typography.css +347 -0
  125. package/dist/helpers/visibility.css +134 -0
  126. package/dist/integrations/fontawesome-font-display-fix.css +67 -0
  127. package/dist/integrations/webawesome-bridge.css +195 -0
  128. package/dist/js/audio-player.js +942 -0
  129. package/dist/js/backdrop.js +119 -0
  130. package/dist/js/code-block.js +238 -0
  131. package/dist/js/combobox.js +382 -0
  132. package/dist/js/command-fallback.js +35 -0
  133. package/dist/js/command-palette.js +477 -0
  134. package/dist/js/compare.js +73 -0
  135. package/dist/js/content-observer.js +82 -0
  136. package/dist/js/count-up.js +150 -0
  137. package/dist/js/countdown.js +185 -0
  138. package/dist/js/dialog-light-dismiss.js +123 -0
  139. package/dist/js/dismiss.js +144 -0
  140. package/dist/js/downloads.js +181 -0
  141. package/dist/js/dropdown.js +300 -0
  142. package/dist/js/dropzone.js +304 -0
  143. package/dist/js/events.js +501 -0
  144. package/dist/js/filter.js +177 -0
  145. package/dist/js/hero-video-motion.js +37 -0
  146. package/dist/js/hide-on-scroll-fallback.js +102 -0
  147. package/dist/js/hovercard.js +228 -0
  148. package/dist/js/icon.js +166 -0
  149. package/dist/js/ics.js +290 -0
  150. package/dist/js/lightbox.js +144 -0
  151. package/dist/js/livesearch.js +253 -0
  152. package/dist/js/map.js +625 -0
  153. package/dist/js/marquee.js +108 -0
  154. package/dist/js/modal-router.js +298 -0
  155. package/dist/js/nav-drilldown.js +250 -0
  156. package/dist/js/nav-priority.js +221 -0
  157. package/dist/js/nav.js +28 -0
  158. package/dist/js/ncss-container.js +117 -0
  159. package/dist/js/notification.js +372 -0
  160. package/dist/js/page-transitions-quiet.js +44 -0
  161. package/dist/js/preferences-early.js +51 -0
  162. package/dist/js/preferences.js +346 -0
  163. package/dist/js/reveal.js +79 -0
  164. package/dist/js/scroll-frames.js +284 -0
  165. package/dist/js/scroll-horizontal.js +121 -0
  166. package/dist/js/scroll-stack-fallback.js +250 -0
  167. package/dist/js/scroll-video.js +332 -0
  168. package/dist/js/scrolly.js +109 -0
  169. package/dist/js/slideshow.js +416 -0
  170. package/dist/js/sortable.js +530 -0
  171. package/dist/js/sparkline.js +199 -0
  172. package/dist/js/spotlight.js +104 -0
  173. package/dist/js/subnav.js +163 -0
  174. package/dist/js/table-sort.js +312 -0
  175. package/dist/js/tabs.js +243 -0
  176. package/dist/js/text-reveal.js +108 -0
  177. package/dist/js/theme-toggle-early.js +28 -0
  178. package/dist/js/theme-toggle.js +135 -0
  179. package/dist/js/toolbar.js +130 -0
  180. package/dist/js/tooltip.js +214 -0
  181. package/dist/js/video-bg.js +193 -0
  182. package/dist/js/video-card.js +80 -0
  183. package/dist/js/video-float.js +119 -0
  184. package/dist/js/video-player.js +1267 -0
  185. package/dist/js/view-transitions.js +118 -0
  186. package/dist/js/wa-close-on-scroll.js +56 -0
  187. package/dist/ncss.css +165 -0
  188. package/dist/page-transitions.css +150 -0
  189. package/dist/reset.css +196 -0
  190. package/dist/theme.css +112 -0
  191. package/dist/tokens.css +238 -0
  192. package/package.json +52 -4
@@ -0,0 +1,332 @@
1
+ /**
2
+ * ncss - <ncss-scroll-video>: Scrollen spult ein Video vor UND zurück (Scroll-Position
3
+ * -> video.currentTime). Light-DOM-Custom-Element, Optik: components/scroll-video.css.
4
+ *
5
+ * 1. Angepinnt (Standard): das Element wird so hoch wie length (Scroll-Strecke), die
6
+ * Bühne bleibt sticky im Bild, das Video füllt sie randlos (object-fit: cover):
7
+ * <ncss-scroll-video length="300">
8
+ * <div class="ncss-scroll-video-stage">
9
+ * <video muted playsinline controls preload="metadata" poster="poster.jpg"
10
+ * src="scrub.mp4"></video>
11
+ * <p class="ncss-scroll-video-caption" data-ncss-time="1-3">Text ...</p>
12
+ * </div>
13
+ * </ncss-scroll-video>
14
+ *
15
+ * 2. inline: kein Anpinnen - das Video spult, während es den Viewport durchquert
16
+ * (unterer Rand kommt rein -> oberer Rand geht raus).
17
+ *
18
+ * 3. Scrollytelling: innerhalb von <ncss-scrolly> (js/scrolly.js) folgt das Video den
19
+ * Schritten. Jeder .ncss-scrolly-step trägt data-ncss-time="2" (springt auf 2 s,
20
+ * solange der Schritt aktiv ist) oder data-ncss-time="2-4" (spult von 2 auf 4 s,
21
+ * während der Schritt die Auslöse-Linie kreuzt). Die Position wird aus der
22
+ * Geometrie der Schritte berechnet (läuft auch ohne scrolly.js); zusätzlich hört das
23
+ * Element auf das "ncss-scrolly-step"-Event von <ncss-scrolly> (detail.time) - bei
24
+ * reduzierter Bewegung springt es damit pro Schritt hart auf die Startzeit, statt zu
25
+ * spulen. Das Element wird dort automatisch inline (die Scrolly-Bühne ist schon sticky).
26
+ *
27
+ * Attribute: start / end (Sekunden-Bereich, auf den die Scroll-Strecke abgebildet wird,
28
+ * end = Default Dauer) · length="300" (Scroll-Strecke in % der Viewport-Höhe) ·
29
+ * smoothing="0.85" (0 = direkt, bis 0.98 = träge nachlaufend) · inline · line="50"
30
+ * (Auslöse-Linie für Schritte, % von oben).
31
+ * Öffentlich: el.progress (0-1), el.time (angefragte Zeit), el.active, el.refresh().
32
+ * Events (bubbeln): ncss-scroll-video-change { progress, time } (gedrosselt auf rAF).
33
+ *
34
+ * Seeking: höchstens EIN Seek gleichzeitig, der nächste startet erst bei "seeked" -
35
+ * schnelles Scrollen staut so keine Seeks auf. fastSeek() (WebKit/Gecko) nur bei großem
36
+ * Abstand, das letzte Bild ist immer exakt. Für flüssiges Spulen in Safari das Video
37
+ * all-intra (jedes Bild ein Keyframe) oder mit sehr kurzer GOP kodieren - ffmpeg-Befehle
38
+ * in der Doku (video-audio.html, "Kodieren").
39
+ *
40
+ * Inaktiv (normales Video mit nativen Controls + Poster, nicht angepinnt, Captions
41
+ * untereinander): bei prefers-reduced-motion (außer Scrollytelling, s.o.),
42
+ * prefers-reduced-data oder Save-Data. Ohne JS: dasselbe.
43
+ *
44
+ * Benötigt: components/scroll-video.css (+ tokens.css/colors.css). Keine anderen
45
+ * ncss-Scripts (scrolly.js ist optional, nur für den Event-Weg).
46
+ */
47
+ (function () {
48
+ "use strict";
49
+ // Bewegung reduzieren? Systemeinstellung ODER ausdrückliche Wahl am <html>
50
+ // (data-motion="reduce"/"full", gesetzt von js/preferences.js) - "full" hebt ein
51
+ // System-"reduce" nur als bewusste Nutzerwahl auf, nie von selbst.
52
+ function ncssReducedMotion() {
53
+ var choice = document.documentElement.getAttribute("data-motion");
54
+ if (choice === "reduce") return true;
55
+ if (choice === "full") return false;
56
+ return !!(window.matchMedia && window.matchMedia("(prefers-reduced-motion: reduce)").matches);
57
+ }
58
+
59
+ if (!window.customElements || typeof IntersectionObserver === "undefined" ||
60
+ typeof requestAnimationFrame !== "function" || customElements.get("ncss-scroll-video")) {
61
+ return;
62
+ }
63
+
64
+ function clamp(v, a, b) {
65
+ return Math.min(b, Math.max(a, v));
66
+ }
67
+ // "2" -> [2, 2], "1-3" / "1 3" / "1,3" -> [1, 3]
68
+ function parseRange(value) {
69
+ var n = String(value === null || value === undefined ? "" : value).split(/\s*[-–,\s]\s*/).filter(Boolean).map(Number).filter(function (v) { return !isNaN(v); });
70
+ return n.length ? [n[0], n.length > 1 ? n[1] : n[0]] : null;
71
+ }
72
+ var motionQuery = window.matchMedia("(prefers-reduced-motion: reduce)");
73
+ function saveData() {
74
+ return !!(navigator.connection && navigator.connection.saveData) || window.matchMedia("(prefers-reduced-data: reduce)").matches;
75
+ }
76
+
77
+ customElements.define(
78
+ "ncss-scroll-video",
79
+ class extends HTMLElement {
80
+ connectedCallback() {
81
+ if (this._video) {
82
+ return;
83
+ }
84
+ this._video = this.querySelector("video");
85
+ if (!this._video) {
86
+ return;
87
+ }
88
+ this._init();
89
+ }
90
+
91
+ disconnectedCallback() {
92
+ if (this._io) {
93
+ this._io.disconnect();
94
+ }
95
+ cancelAnimationFrame(this._raf);
96
+ window.removeEventListener("scroll", this._schedule);
97
+ window.removeEventListener("resize", this._schedule);
98
+ }
99
+
100
+ get progress() {
101
+ return this._progress || 0;
102
+ }
103
+ get time() {
104
+ return this._current === null || this._current === undefined ? (this._video ? this._video.currentTime : 0) : this._current;
105
+ }
106
+ get active() {
107
+ return !!this._active;
108
+ }
109
+ refresh() {
110
+ if (this._refresh) {
111
+ this._refresh();
112
+ }
113
+ }
114
+
115
+ _init() {
116
+ var el = this;
117
+ var video = this._video;
118
+ var scrolly = el.closest("ncss-scrolly");
119
+ var steps = scrolly ? Array.prototype.slice.call(scrolly.querySelectorAll(".ncss-scrolly-step[data-ncss-time]")) : [];
120
+ var inline = el.hasAttribute("inline") || !!scrolly;
121
+ var captions = Array.prototype.slice.call(el.querySelectorAll(".ncss-scroll-video-caption[data-ncss-time]"));
122
+ var smoothAttr = el.getAttribute("smoothing");
123
+ var smoothing = clamp(smoothAttr === null ? 0.85 : Number(smoothAttr) || 0, 0, 0.98);
124
+ var linePct = parseFloat(el.getAttribute("line")) || 50;
125
+ var hadControls = video.controls;
126
+ if (inline) {
127
+ el.classList.add("is-inline");
128
+ }
129
+ if (el.getAttribute("length")) {
130
+ el.style.setProperty("--ncss-scroll-video-length", parseFloat(el.getAttribute("length")) + "lvh");
131
+ }
132
+
133
+ var active = false;
134
+ var stepwise = false; // reduzierte Bewegung im Scrollytelling: springen statt spulen
135
+ var near = false;
136
+ var raf = 0;
137
+ var last = 0;
138
+ var current = null;
139
+ var target = 0;
140
+ var seekBusy = false;
141
+ var lastEmit = -1;
142
+
143
+ function duration() {
144
+ return isFinite(video.duration) ? video.duration : 0;
145
+ }
146
+ function range() {
147
+ var d = duration();
148
+ var s = clamp(Number(el.getAttribute("start")) || 0, 0, d);
149
+ var e = el.getAttribute("end");
150
+ return [s, e === null || e === "" ? d : clamp(Number(e), s, d)];
151
+ }
152
+
153
+ function computeTarget() {
154
+ var vh = window.innerHeight;
155
+ if (steps.length) {
156
+ var line = vh * linePct / 100;
157
+ var t = null;
158
+ var done = 0;
159
+ for (var i = 0; i < steps.length; i++) {
160
+ var r = steps[i].getBoundingClientRect();
161
+ var tr = parseRange(steps[i].getAttribute("data-ncss-time")) || [0, 0];
162
+ if (r.top > line) {
163
+ if (t === null) {
164
+ t = tr[0];
165
+ }
166
+ break;
167
+ }
168
+ done = i + 1;
169
+ if (r.bottom >= line) {
170
+ var p = clamp((line - r.top) / (r.height || 1), 0, 1);
171
+ t = stepwise ? tr[0] : tr[0] + (tr[1] - tr[0]) * p;
172
+ break;
173
+ }
174
+ t = tr[1];
175
+ }
176
+ el._progress = done / steps.length;
177
+ return t === null ? 0 : t;
178
+ }
179
+ var box = el.getBoundingClientRect();
180
+ el._progress = inline ?
181
+ clamp((vh - box.top) / (vh + box.height), 0, 1) :
182
+ clamp(-box.top / Math.max(1, box.height - vh), 0, 1);
183
+ var rg = range();
184
+ return rg[0] + (rg[1] - rg[0]) * el._progress;
185
+ }
186
+
187
+ function seek(time) {
188
+ var d = duration();
189
+ if (!d || seekBusy || video.seeking) {
190
+ return;
191
+ }
192
+ time = clamp(time, 0, d - 0.001); // nicht ganz ans Ende: sonst feuert "ended"
193
+ var diff = Math.abs(video.currentTime - time);
194
+ if (diff < 1 / 120) {
195
+ return;
196
+ }
197
+ seekBusy = true;
198
+ if (typeof video.fastSeek === "function" && diff > 0.5 && Math.abs(target - time) > 0.25) {
199
+ video.fastSeek(time);
200
+ } else {
201
+ video.currentTime = time;
202
+ }
203
+ }
204
+
205
+ function tick(now) {
206
+ raf = 0;
207
+ if (!active) {
208
+ return;
209
+ }
210
+ target = computeTarget();
211
+ var dt = clamp((now - (last || now)) / 16.667, 0, 6);
212
+ last = now;
213
+ if (current === null || stepwise) {
214
+ current = target;
215
+ }
216
+ current += (target - current) * (1 - Math.pow(smoothing, dt));
217
+ if (Math.abs(target - current) < 0.002) {
218
+ current = target;
219
+ }
220
+ el._current = current;
221
+ seek(current);
222
+ captions.forEach(function (c) {
223
+ var r = parseRange(c.getAttribute("data-ncss-time"));
224
+ c.classList.toggle("is-active", !!r && current >= r[0] && current <= r[1] + 0.001);
225
+ });
226
+ if (Math.abs(current - lastEmit) > 0.001) {
227
+ lastEmit = current;
228
+ el.dispatchEvent(new CustomEvent("ncss-scroll-video-change", { bubbles: true, detail: { progress: el._progress, time: current } }));
229
+ }
230
+ var settled = !near || !duration() || (current === target && !seekBusy && Math.abs(video.currentTime - target) < 1 / 60);
231
+ if (!settled) {
232
+ schedule();
233
+ } else {
234
+ last = 0;
235
+ }
236
+ }
237
+ function schedule() {
238
+ if (active && !raf) {
239
+ raf = requestAnimationFrame(tick);
240
+ }
241
+ }
242
+ el._schedule = schedule;
243
+
244
+ function load() {
245
+ if (!near || !active) {
246
+ return;
247
+ }
248
+ if (video.preload !== "auto") {
249
+ video.preload = "auto";
250
+ }
251
+ if (video.readyState === 0 && video.networkState !== HTMLMediaElement.NETWORK_LOADING) {
252
+ video.load();
253
+ }
254
+ }
255
+
256
+ function refresh() {
257
+ var rm = ncssReducedMotion();
258
+ var want = !saveData() && !(rm && !steps.length);
259
+ stepwise = rm && !!steps.length;
260
+ if (want === active) {
261
+ schedule();
262
+ return;
263
+ }
264
+ active = want;
265
+ el._active = active;
266
+ el.classList.toggle("is-active", active);
267
+ if (active) {
268
+ video.controls = false;
269
+ video.muted = true;
270
+ video.playsInline = true;
271
+ video.pause();
272
+ current = null;
273
+ load();
274
+ schedule();
275
+ } else {
276
+ cancelAnimationFrame(raf);
277
+ raf = 0;
278
+ video.controls = hadControls || !steps.length;
279
+ captions.forEach(function (c) { c.classList.remove("is-active"); });
280
+ }
281
+ }
282
+ el._refresh = refresh;
283
+
284
+ el._io = new IntersectionObserver(function (entries) {
285
+ near = entries[entries.length - 1].isIntersecting;
286
+ if (near) {
287
+ load();
288
+ schedule();
289
+ }
290
+ }, { rootMargin: "100% 0px" });
291
+ el._io.observe(el);
292
+
293
+ window.addEventListener("scroll", schedule, { passive: true });
294
+ window.addEventListener("resize", schedule, { passive: true });
295
+ video.addEventListener("seeked", function () {
296
+ seekBusy = false;
297
+ schedule();
298
+ });
299
+ video.addEventListener("loadedmetadata", function () {
300
+ // iOS dekodiert Bilder erst nach einem play() - einmal stumm anstoßen.
301
+ if (active && video.readyState < 2) {
302
+ var p = video.play();
303
+ if (p && p.then) {
304
+ p.then(function () { video.pause(); }).catch(function () {});
305
+ }
306
+ }
307
+ current = null;
308
+ schedule();
309
+ });
310
+ video.addEventListener("ended", function () {
311
+ if (active) {
312
+ video.pause();
313
+ }
314
+ });
315
+ // Scrollytelling-Kopplung: bei reduzierter Bewegung pro Schritt hart springen.
316
+ if (scrolly) {
317
+ scrolly.addEventListener("ncss-scrolly-step", function (event) {
318
+ var time = event.detail && event.detail.time;
319
+ if (stepwise && typeof time === "number" && duration()) {
320
+ current = target = time;
321
+ seekBusy = false;
322
+ video.currentTime = clamp(time, 0, duration() - 0.001);
323
+ }
324
+ schedule();
325
+ });
326
+ }
327
+ motionQuery.addEventListener("change", refresh);
328
+ refresh();
329
+ }
330
+ }
331
+ );
332
+ })();
@@ -0,0 +1,109 @@
1
+ /**
2
+ * ncss - <ncss-scrolly>: Scrollytelling-Element (Markup/Optik: components/scrolly.css).
3
+ * Reines Light-DOM-Custom-Element (kein Shadow Root) - Schritte und Medien bleiben normales
4
+ * Seiten-Markup, ohne dieses Script einfach untereinander lesbar.
5
+ *
6
+ * Markiert den Schritt, der eine waagerechte Linie im Viewport kreuzt (Default: Mitte,
7
+ * Attribut line="50" in % von oben), und das Medium mit demselben Index mit .is-active
8
+ * (IntersectionObserver auf einen 1px hohen Streifen statt Scroll-Listener).
9
+ *
10
+ * API:
11
+ * el.step Index des aktiven Schritts (lesen); el.step = 2 scrollt Schritt 3
12
+ * in die Mitte (respektiert prefers-reduced-motion).
13
+ * "ncss-scrolly-step"-Event bubbelt, detail = { index, time, step, figure }. time = Zahl aus
14
+ * data-ncss-time am Schritt (Sekunden) oder null - Andockpunkt für
15
+ * ein scroll-gesteuertes Video (seeken auf time).
16
+ *
17
+ * Benötigt: components/scrolly.css (+ tokens.css/colors.css). Ohne IntersectionObserver
18
+ * wird das Element gar nicht erst definiert (SKILL-Regel: kein halb funktionierendes
19
+ * :defined) - es bleibt beim lesbaren Fluss-Layout.
20
+ *
21
+ * Einbindung: <script src="ncss/js/scrolly.js" defer></script>
22
+ */
23
+ (function () {
24
+ "use strict";
25
+ // Bewegung reduzieren? Systemeinstellung ODER ausdrückliche Wahl am <html>
26
+ // (data-motion="reduce"/"full", gesetzt von js/preferences.js) - "full" hebt ein
27
+ // System-"reduce" nur als bewusste Nutzerwahl auf, nie von selbst.
28
+ function ncssReducedMotion() {
29
+ var choice = document.documentElement.getAttribute("data-motion");
30
+ if (choice === "reduce") return true;
31
+ if (choice === "full") return false;
32
+ return !!(window.matchMedia && window.matchMedia("(prefers-reduced-motion: reduce)").matches);
33
+ }
34
+
35
+ if (!window.customElements || typeof IntersectionObserver === "undefined" || customElements.get("ncss-scrolly")) {
36
+ return;
37
+ }
38
+
39
+ customElements.define(
40
+ "ncss-scrolly",
41
+ class extends HTMLElement {
42
+ connectedCallback() {
43
+ this._steps = Array.prototype.slice.call(this.querySelectorAll(".ncss-scrolly-step"));
44
+ this._figures = Array.prototype.slice.call(this.querySelectorAll(".ncss-scrolly-figure"));
45
+ this._index = -1;
46
+ if (!this._steps.length) return;
47
+
48
+ var line = parseFloat(this.getAttribute("line"));
49
+ if (!(line >= 0 && line <= 100)) line = 50;
50
+ var self = this;
51
+
52
+ this._io = new IntersectionObserver(
53
+ function (entries) {
54
+ entries.forEach(function (entry) {
55
+ if (entry.isIntersecting) self._activate(self._steps.indexOf(entry.target));
56
+ });
57
+ },
58
+ { rootMargin: "-" + line + "% 0px -" + Math.max(0, 100 - line - 0.1) + "% 0px" }
59
+ );
60
+ this._steps.forEach(function (step) {
61
+ self._io.observe(step);
62
+ });
63
+
64
+ // Startzustand: letzter Schritt, dessen Oberkante schon über der Linie liegt.
65
+ var y = (window.innerHeight * line) / 100;
66
+ var best = 0;
67
+ this._steps.forEach(function (step, k) {
68
+ if (step.getBoundingClientRect().top <= y) best = k;
69
+ });
70
+ this._activate(best);
71
+ }
72
+
73
+ disconnectedCallback() {
74
+ if (this._io) this._io.disconnect();
75
+ }
76
+
77
+ get step() {
78
+ return this._index;
79
+ }
80
+
81
+ set step(i) {
82
+ var target = this._steps && this._steps[i];
83
+ if (!target) return;
84
+ var reduce = ncssReducedMotion();
85
+ target.scrollIntoView({ block: "center", behavior: reduce ? "instant" : "smooth" });
86
+ }
87
+
88
+ _activate(i) {
89
+ if (i < 0 || i === this._index) return;
90
+ this._index = i;
91
+ var step = this._steps[i];
92
+ var figure = this._figures[Math.min(i, this._figures.length - 1)] || null;
93
+ this._steps.forEach(function (s, k) {
94
+ s.classList.toggle("is-active", k === i);
95
+ });
96
+ this._figures.forEach(function (f) {
97
+ f.classList.toggle("is-active", f === figure);
98
+ });
99
+ var time = parseFloat(step.getAttribute("data-ncss-time"));
100
+ this.dispatchEvent(
101
+ new CustomEvent("ncss-scrolly-step", {
102
+ bubbles: true,
103
+ detail: { index: i, time: isNaN(time) ? null : time, step: step, figure: figure }
104
+ })
105
+ );
106
+ }
107
+ }
108
+ );
109
+ })();