transitionEmit.js 668 B

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