@@ -13,6 +13,7 @@ import Indicator from '@/packages/indicator/index'
1313import { BasicComponent } from '@/utils/typings'
1414import { useTouch } from '@/utils/use-touch'
1515import requestAniFrame from '@/utils/raf'
16+ import { useRtl } from '@/packages/configprovider'
1617
1718export type SwiperRef = {
1819 to : ( index : number ) => void
@@ -59,6 +60,7 @@ export const Swiper = React.forwardRef<
5960 SwiperRef ,
6061 Partial < SwiperProps > & Omit < React . HTMLAttributes < HTMLDivElement > , 'onChange' >
6162> ( ( props , ref ) => {
63+ const rtl = useRtl ( )
6264 const mergedProps = { ...defaultProps , ...props }
6365 const {
6466 children,
@@ -304,7 +306,7 @@ export const Swiper = React.forwardRef<
304306 isVertical ? width : height
305307 } px`
306308 target . style . transform = `translate3D${
307- ! isVertical ? `(${ _offset } px,0,0)` : `(0,${ _offset } px,0)`
309+ ! isVertical ? `(${ rtl ? - _offset : _offset } px,0,0)` : `(0,${ _offset } px,0)`
308310 } `
309311 }
310312
@@ -369,7 +371,9 @@ export const Swiper = React.forwardRef<
369371 const offset = childOffset [ index ]
370372 if ( offset ) {
371373 style . transform = `translate3D${
372- direction === 'horizontal' ? `(${ offset } px,0,0)` : `(0,${ offset } px,0)`
374+ direction === 'horizontal'
375+ ? `(${ rtl ? - offset : offset } px,0,0)`
376+ : `(0,${ offset } px,0)`
373377 } `
374378 }
375379 return style
0 commit comments