transitionEmit.js 703 B

123456789101112131415161718192021222324252627282930313233
  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';else if (activeIndex < previousIndex) dir = 'prev';else dir = 'reset';
  14. }
  15. swiper.emit(`transition${step}`);
  16. if (runCallbacks && activeIndex !== previousIndex) {
  17. if (dir === 'reset') {
  18. swiper.emit(`slideResetTransition${step}`);
  19. return;
  20. }
  21. swiper.emit(`slideChangeTransition${step}`);
  22. if (dir === 'next') {
  23. swiper.emit(`slideNextTransition${step}`);
  24. } else {
  25. swiper.emit(`slidePrevTransition${step}`);
  26. }
  27. }
  28. }