transitionEmit.js 732 B

12345678910111213141516171819202122232425262728293031323334
  1. export default function transitionEmit(_ref) {
  2. let {
  3. swiper,
  4. runCallbacks,
  5. direction,
  6. step
  7. } = _ref;
  8. const {
  9. activeIndex,
  10. previousIndex
  11. } = swiper;
  12. let dir = direction;
  13. if (!dir) {
  14. if (activeIndex > previousIndex) dir = 'next';else if (activeIndex < previousIndex) dir = 'prev';else dir = 'reset';
  15. }
  16. swiper.emit(`transition${step}`);
  17. if (runCallbacks && activeIndex !== previousIndex) {
  18. if (dir === 'reset') {
  19. swiper.emit(`slideResetTransition${step}`);
  20. return;
  21. }
  22. swiper.emit(`slideChangeTransition${step}`);
  23. if (dir === 'next') {
  24. swiper.emit(`slideNextTransition${step}`);
  25. } else {
  26. swiper.emit(`slidePrevTransition${step}`);
  27. }
  28. }
  29. }