@karmo-co/drift-kit-public 25.20.0 → 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
@@ -7912,12 +7912,25 @@
7912
7912
  svg.appendChild(defs);
7913
7913
  el.appendChild(svg);
7914
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
+ }
7915
7927
  function play(el, state) {
7916
7928
  if (el.getAttribute('data-animation') === state) {
7917
7929
  el.removeAttribute('data-animation');
7918
7930
  void el.offsetWidth;
7919
7931
  }
7920
7932
  el.setAttribute('data-animation', state);
7933
+ return ended(el);
7921
7934
  }
7922
7935
  function init(scope) {
7923
7936
  var root = scope && scope.querySelectorAll ? scope : document;
@@ -7940,6 +7953,7 @@
7940
7953
  }
7941
7954
  api.init = init;
7942
7955
  api.play = play;
7956
+ api.ended = ended;
7943
7957
  document.addEventListener('DOMContentLoaded', function () { init(document); });
7944
7958
  })();
7945
7959
  })(typeof window !== 'undefined' ? window : undefined);