@karmo-co/drift-kit-public 25.12.0 → 25.14.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.
package/components.js CHANGED
@@ -323,6 +323,73 @@
323
323
  dk.motion.reduced = reduced;
324
324
  })();
325
325
  })(typeof window !== 'undefined' ? window : undefined);
326
+ (function (w) {
327
+ if (!w)
328
+ return;
329
+ var d = (w.dk = w.dk || {});
330
+ d.__loaded = d.__loaded || {};
331
+ if (d.__loaded['kit/scrollbar.js'])
332
+ return;
333
+ d.__loaded['kit/scrollbar.js'] = true;
334
+ (function () {
335
+ 'use strict';
336
+ var dk = (window.dk = window.dk || {});
337
+ if (dk.scrollbar)
338
+ return;
339
+ var A = 'data-scrollbar-reveal', S = 'data-scrolling';
340
+ var ends = 'onscrollend' in window;
341
+ function quiet(el) {
342
+ return dk.motion && dk.motion.timing ? dk.motion.timing('state', { el: el }).duration : 0;
343
+ }
344
+ function arrival(el) {
345
+ return dk.motion && dk.motion.timing ? dk.motion.timing('state-enter', { el: el }).duration : 0;
346
+ }
347
+ function now() { return window.performance && performance.now ? performance.now() : Date.now(); }
348
+ function clear(el) {
349
+ clearTimeout(el.__dkScrollbarQuiet);
350
+ el.__dkScrollbarQuiet = null;
351
+ }
352
+ function stop(el) {
353
+ clear(el);
354
+ var wait = arrival(el) - (now() - (el.__dkScrollbarSince || 0));
355
+ if (wait > 0) {
356
+ el.__dkScrollbarQuiet = setTimeout(function () { stop(el); }, wait);
357
+ return;
358
+ }
359
+ el.removeAttribute(S);
360
+ }
361
+ function start(el) {
362
+ if (!el.hasAttribute(S)) {
363
+ el.setAttribute(S, '');
364
+ el.__dkScrollbarSince = now();
365
+ }
366
+ clear(el);
367
+ }
368
+ function mark(el) {
369
+ start(el);
370
+ el.__dkScrollbarQuiet = setTimeout(function () { stop(el); }, quiet(el) * (ends ? 4 : 1));
371
+ }
372
+ function scroller(e) {
373
+ var t = e.target;
374
+ if (t === document)
375
+ t = document.scrollingElement || document.documentElement;
376
+ return t && t.nodeType === 1 && t.hasAttribute(A) ? t : null;
377
+ }
378
+ document.addEventListener('scroll', function (e) { var el = scroller(e); if (el)
379
+ mark(el); }, { capture: true, passive: true });
380
+ if (ends)
381
+ document.addEventListener('scrollend', function (e) { var el = scroller(e); if (el)
382
+ stop(el); }, { capture: true, passive: true });
383
+ dk.scrollbar = {
384
+ flash: function (el) {
385
+ if (!el || !el.hasAttribute(A))
386
+ return;
387
+ start(el);
388
+ el.__dkScrollbarQuiet = setTimeout(function () { stop(el); }, quiet(el));
389
+ }
390
+ };
391
+ })();
392
+ })(typeof window !== 'undefined' ? window : undefined);
326
393
  (function (w) {
327
394
  if (!w)
328
395
  return;
@@ -354,41 +421,46 @@
354
421
  }
355
422
  function walk(container, beat, max) {
356
423
  var kids = Array.prototype.slice.call(container.children);
357
- for (var k = 0; k < kids.length; k++) {
358
- var el = kids[k];
359
- if (el.hasAttribute(A + '-skip') || el.tagName === 'SCRIPT' || el.tagName === 'STYLE')
360
- continue;
361
- if (el.hasAttribute(A + '-through')) {
362
- beat = walk(el, beat, max);
363
- continue;
364
- }
365
- if (el.hasAttribute(A + '-grid')) {
366
- var rowTop = null, cards = Array.prototype.slice.call(el.children);
367
- for (var c = 0; c < cards.length; c++) {
368
- var top = cards[c].offsetTop;
369
- if (rowTop === null)
370
- rowTop = top;
371
- else if (Math.abs(top - rowTop) > 4) {
372
- beat += 1;
373
- rowTop = top;
374
- }
375
- set(cards[c], beat, max);
376
- }
377
- beat += 1;
378
- continue;
379
- }
380
- if (el.hasAttribute(A + '-list')) {
381
- var rows = Array.prototype.slice.call(el.children);
382
- for (var r = 0; r < rows.length; r++)
383
- set(rows[r], beat + r * 0.5, max);
384
- beat += rows.length ? (rows.length - 1) * 0.5 + 1 : 0;
385
- continue;
386
- }
387
- set(el, beat, max);
388
- beat += 1;
389
- }
424
+ for (var k = 0; k < kids.length; k++)
425
+ beat = unit(kids[k], beat, max);
390
426
  return beat;
391
427
  }
428
+ function unit(el, beat, max) {
429
+ if (el.hasAttribute(A + '-skip') || el.tagName === 'SCRIPT' || el.tagName === 'STYLE')
430
+ return beat;
431
+ if (getComputedStyle(el).getPropertyValue('display') === 'none')
432
+ return beat;
433
+ if (el.hasAttribute(A + '-through') && el.hasAttribute(A + '-parallel')) {
434
+ var cols = Array.prototype.slice.call(el.children), end = beat;
435
+ for (var p = 0; p < cols.length; p++)
436
+ end = Math.max(end, unit(cols[p], beat, max));
437
+ return end;
438
+ }
439
+ if (el.hasAttribute(A + '-through'))
440
+ return walk(el, beat, max);
441
+ if (el.hasAttribute(A + '-grid')) {
442
+ var rowTop = null, cards = Array.prototype.slice.call(el.children);
443
+ for (var c = 0; c < cards.length; c++) {
444
+ var top = cards[c].offsetTop;
445
+ if (rowTop === null)
446
+ rowTop = top;
447
+ else if (Math.abs(top - rowTop) > 4) {
448
+ beat += 1;
449
+ rowTop = top;
450
+ }
451
+ set(cards[c], beat, max);
452
+ }
453
+ return beat + 1;
454
+ }
455
+ if (el.hasAttribute(A + '-list')) {
456
+ var rows = Array.prototype.slice.call(el.children);
457
+ for (var r = 0; r < rows.length; r++)
458
+ set(rows[r], beat + r * 0.5, max);
459
+ return beat + (rows.length ? (rows.length - 1) * 0.5 + 1 : 0);
460
+ }
461
+ set(el, beat, max);
462
+ return beat + 1;
463
+ }
392
464
  function reveal(root) {
393
465
  if (!root || root.__dkCascaded)
394
466
  return;
@@ -9088,9 +9160,23 @@
9088
9160
  }
9089
9161
  var authored = root.getAttribute('data-orientation');
9090
9162
  var turned = false;
9163
+ function wraps() {
9164
+ if (root.getAttribute('data-orientation') === 'vertical')
9165
+ return false;
9166
+ collect();
9167
+ if (steps.length < 2)
9168
+ return false;
9169
+ var was = root.hasAttribute('data-narrow');
9170
+ if (was)
9171
+ root.removeAttribute('data-narrow');
9172
+ var wrapped = steps[steps.length - 1].offsetTop > steps[0].offsetTop;
9173
+ if (was)
9174
+ root.setAttribute('data-narrow', '');
9175
+ return wrapped;
9176
+ }
9091
9177
  function measure() {
9092
9178
  var w = root.getBoundingClientRect().width;
9093
- var narrow = !!(w && w < narrowPx());
9179
+ var narrow = !!(w && (w < narrowPx() || wraps()));
9094
9180
  if (narrow)
9095
9181
  root.setAttribute('data-narrow', '');
9096
9182
  else