effect-virtual-transition-end.js 982 B

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