UNPKG

@zebra-ui/swiper

Version:

专为多端设计的高性能swiper轮播组件库,支持多种复杂的 3D swiper轮播效果。

30 lines (21 loc) 786 B
import { getTranslate } from '../../shared/utils' import type { GetTranslate } from '../../../types/components/core/translate/get-translate' import type { SwiperInterface } from '../../../types/swiper-class' const getSwiperTranslate: GetTranslate = function ( this: SwiperInterface, axis = this.isHorizontal() ? 'x' : 'y' ) { const swiper = this const { params, rtlTranslate: rtl, translate, wrapperEl } = swiper if (params.virtualTranslate) { return rtl ? -translate : translate } if (params.cssMode) { return translate } let currentTranslate = getTranslate(wrapperEl, axis, swiper) currentTranslate += swiper.cssOverflowAdjustment() if (rtl) currentTranslate = -currentTranslate return currentTranslate || 0 } export default getSwiperTranslate