@karmo-co/drift-kit-public 25.19.1 → 25.21.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
@@ -384,6 +384,12 @@
384
384
  if (dk.scrollbar)
385
385
  return;
386
386
  var A = 'data-scrollbar-reveal', S = 'data-scrolling';
387
+ var KIT = '.dk-component-sidebar__body, .dk-component-sidebar__panel-body';
388
+ function revealed(t) {
389
+ if (t.hasAttribute(A))
390
+ return t.getAttribute(A) !== 'always';
391
+ return t.matches(KIT) && !t.closest('[' + A + '="always"]');
392
+ }
387
393
  var ends = 'onscrollend' in window;
388
394
  function quiet(el) {
389
395
  return dk.motion && dk.motion.timing ? dk.motion.timing('state', { el: el }).duration : 0;
@@ -420,7 +426,7 @@
420
426
  var t = e.target;
421
427
  if (t === document)
422
428
  t = document.scrollingElement || document.documentElement;
423
- return t && t.nodeType === 1 && t.hasAttribute(A) ? t : null;
429
+ return t && t.nodeType === 1 && revealed(t) ? t : null;
424
430
  }
425
431
  document.addEventListener('scroll', function (e) { var el = scroller(e); if (el)
426
432
  mark(el); }, { capture: true, passive: true });
@@ -429,7 +435,7 @@
429
435
  stop(el); }, { capture: true, passive: true });
430
436
  dk.scrollbar = {
431
437
  flash: function (el) {
432
- if (!el || !el.hasAttribute(A))
438
+ if (!el || !revealed(el))
433
439
  return;
434
440
  start(el);
435
441
  el.__dkScrollbarQuiet = setTimeout(function () { stop(el); }, quiet(el));
@@ -7906,12 +7912,25 @@
7906
7912
  svg.appendChild(defs);
7907
7913
  el.appendChild(svg);
7908
7914
  }
7915
+ function ended(el) {
7916
+ var state = el.getAttribute('data-animation');
7917
+ var turn = el.__dkShieldTurn = (el.__dkShieldTurn || 0) + 1;
7918
+ var list = el.getAnimations ? el.getAnimations({ subtree: true }) : [];
7919
+ return Promise.all(list.map(function (a) { return a.finished; })).then(function () { return true; }, function () { return false; })
7920
+ .then(function (ok) {
7921
+ if (!ok || el.__dkShieldTurn !== turn)
7922
+ return false;
7923
+ el.dispatchEvent(new CustomEvent('dk-component-shield:animation-end', { bubbles: true, detail: { animation: state } }));
7924
+ return true;
7925
+ });
7926
+ }
7909
7927
  function play(el, state) {
7910
7928
  if (el.getAttribute('data-animation') === state) {
7911
7929
  el.removeAttribute('data-animation');
7912
7930
  void el.offsetWidth;
7913
7931
  }
7914
7932
  el.setAttribute('data-animation', state);
7933
+ return ended(el);
7915
7934
  }
7916
7935
  function init(scope) {
7917
7936
  var root = scope && scope.querySelectorAll ? scope : document;
@@ -7934,6 +7953,7 @@
7934
7953
  }
7935
7954
  api.init = init;
7936
7955
  api.play = play;
7956
+ api.ended = ended;
7937
7957
  document.addEventListener('DOMContentLoaded', function () { init(document); });
7938
7958
  })();
7939
7959
  })(typeof window !== 'undefined' ? window : undefined);