effect-virtual-transition-end.js 940 B

123456789101112131415161718192021222324252627282930313233343536
  1. export default function effectVirtualTransitionEnd(_ref) {
  2. let {
  3. swiper,
  4. duration,
  5. transformEl,
  6. allSlides
  7. } = _ref;
  8. const {
  9. slides,
  10. activeIndex,
  11. $wrapperEl
  12. } = swiper;
  13. if (swiper.params.virtualTranslate && duration !== 0) {
  14. let eventTriggered = false;
  15. let $transitionEndTarget;
  16. if (allSlides) {
  17. $transitionEndTarget = transformEl ? slides.find(transformEl) : slides;
  18. } else {
  19. $transitionEndTarget = transformEl ? slides.eq(activeIndex).find(transformEl) : slides.eq(activeIndex);
  20. }
  21. $transitionEndTarget.transitionEnd(() => {
  22. if (eventTriggered) return;
  23. if (!swiper || swiper.destroyed) return;
  24. eventTriggered = true;
  25. swiper.animating = false;
  26. const triggerEvents = ['webkitTransitionEnd', 'transitionend'];
  27. for (let i = 0; i < triggerEvents.length; i += 1) {
  28. $wrapperEl.trigger(triggerEvents[i]);
  29. }
  30. });
  31. }
  32. }