getTranslate.js 496 B

1234567891011121314151617181920212223
  1. import {
  2. getTranslate
  3. } from '../../shared/utils.js';
  4. export default function getSwiperTranslate(axis = this.isHorizontal() ? 'x' : 'y') {
  5. const swiper = this;
  6. const {
  7. params,
  8. rtlTranslate: rtl,
  9. translate,
  10. $wrapperEl
  11. } = swiper;
  12. if (params.virtualTranslate) {
  13. return rtl ? -translate : translate;
  14. }
  15. if (params.cssMode) {
  16. return translate;
  17. }
  18. let currentTranslate = getTranslate(swiper, axis);
  19. if (rtl) currentTranslate = -currentTranslate;
  20. return currentTranslate || 0;
  21. }