-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dynamic RTL change #3279
Comments
It is by design, it can be initialized when it is rtl or not, and it’s behavior can’t be changed after init. If you really need such behavior you can destroy and reinit Swiper in this case |
@nolimits4web Why? It seems that it is already working just fine as is. Why not include it in the official documention?
seems to correctly causes the slider to switch directions properly. |
is it possible add direction changes in to the observe parameter? or when call update method update slider direction too? |
This is working great without the rtl property. ReactJs example: import React, { useEffect, useState } from 'react'
import { Swiper, SwiperSlide } from 'swiper/react'
import { Swiper as SwiperInstance } from 'swiper'
import i18n from 'i18next'
const Slider = () => {
const [swiper, setSwiper] = useState<SwiperInstance | null>(null)
useEffect(() => {
if (swiper) {
swiper.rtlTranslate = i18n?.dir() === 'rtl'
}
}, [swiper, i18n?.dir()])
return (
<Swiper
spaceBetween={50}
slidesPerView={3}
onSwiper={(swiper : SwiperInstance) => setSwiper(swiper)}
>
<SwiperSlide>Slide 1</SwiperSlide>
<SwiperSlide>Slide 2</SwiperSlide>
<SwiperSlide>Slide 3</SwiperSlide>
<SwiperSlide>Slide 4</SwiperSlide>
...
</Swiper>
)
} |
Seems like it doesn't reset margins that were added by |
bug
enhancement
feature-discussion (RFC)
Swiper Version: 5.0.4
Platform/Target and Browser Versions: Windows - Chrome 77.0.3865.120
Codepen: https://codepen.io/codesignist/pen/VwwaqNj
What you did
I've changed html direction to "rtl" by JS.
Expected Behavior
RTL change should affect Swiper and should work from right to left as expected.
Actual Behavior
RTL change doesn't make any effect on Swiper.
The text was updated successfully, but these errors were encountered: