Landscape mode
74io opened this issue ยท 13 comments
Great module! Any pointers on how to get it working when changing the device orientation to landscape?
+1 afaik it does not support landscape?
Looks related to #16
Any suggestions for making react-native-swiper work in landscape mode?
Thanks for a great component!
Any news on this ?
+1
+1 too. It works on first load, but dimensions do not update upon rotating device. Even when manually updating Swiper width after device rotation, it doesn't actually update.
+1
+1 too. I've tried so many ways to force the update after device rotation, like invert width and height, but it's not a good practice at all.
Someone did find a decent solution ?
The problem is that Swiper gets windows dimensions one time on execute rather than on render, but I've worked around this by getting window dimensions in my render function and passing those values to the width
and height
props of <Swiper>
.
render () {
const { width, height } = Dimensions.get('window')
return (
<Swiper width={width} height={height}>
...
</Swiper>
)
}
When the window dimensions change, Swiper's componentWillReceiveProps
method is called, which updates the dimensions in its state.
@timmywil Yup
Though ultimately I don't think Swiper even has a reason to try using the window dimensions to fill the page. It makes much more sense to use flex
and onLayout
.
Seems this broke again when I updated react-native to 0.46.2. componentWillReceiveProps
isn't called anymore. This project doesn't seem to be getting support anymore, so I may fork it or just build a custom one for my needs.
@timmywil Does this properly change orientation to landscape now? I've been unable to get that working so far.
Is it working now ?