vrembem 3.0.13 → 3.0.14

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.
@@ -634,16 +634,27 @@
634
634
 
635
635
  var openTransition = function openTransition(el, settings) {
636
636
  return new Promise(function (resolve) {
637
+ // Check if transitions are enabled.
637
638
  if (settings.transition) {
639
+ // Toggle classes for opening transition.
638
640
  el.classList.remove(settings.stateClosed);
639
641
  el.classList.add(settings.stateOpening);
640
- el.addEventListener('transitionend', function _f() {
642
+
643
+ // Add event listener for when the transition is finished.
644
+ el.addEventListener('transitionend', function _f(event) {
645
+ // Prevent child transition bubbling from firing this event.
646
+ if (event.target != el) return;
647
+
648
+ // Toggle final opened state classes.
641
649
  el.classList.add(settings.stateOpened);
642
650
  el.classList.remove(settings.stateOpening);
651
+
652
+ // Resolve the promise and remove the event listener.
643
653
  resolve(el);
644
654
  this.removeEventListener('transitionend', _f);
645
655
  });
646
656
  } else {
657
+ // Toggle final opened state classes and resolve the promise.
647
658
  el.classList.add(settings.stateOpened);
648
659
  el.classList.remove(settings.stateClosed);
649
660
  resolve(el);
@@ -652,16 +663,27 @@
652
663
  };
653
664
  var closeTransition = function closeTransition(el, settings) {
654
665
  return new Promise(function (resolve) {
666
+ // Check if transitions are enabled.
655
667
  if (settings.transition) {
668
+ // Toggle classes for closing transition.
656
669
  el.classList.add(settings.stateClosing);
657
670
  el.classList.remove(settings.stateOpened);
658
- el.addEventListener('transitionend', function _f() {
671
+
672
+ // Add event listener for when the transition is finished.
673
+ el.addEventListener('transitionend', function _f(event) {
674
+ // Prevent child transition bubbling from firing this event.
675
+ if (event.target != el) return;
676
+
677
+ // Toggle final closed state classes.
659
678
  el.classList.remove(settings.stateClosing);
660
679
  el.classList.add(settings.stateClosed);
680
+
681
+ // Resolve the promise and remove the event listener.
661
682
  resolve(el);
662
683
  this.removeEventListener('transitionend', _f);
663
684
  });
664
685
  } else {
686
+ // Toggle final closed state classes and resolve the promise.
665
687
  el.classList.add(settings.stateClosed);
666
688
  el.classList.remove(settings.stateOpened);
667
689
  resolve(el);