-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Content doesn't stretch when rotate (portrait mode) #16
Comments
I'm seeing this also, the inspector shows that the calculated width is always 375 regardless of content or orientation. If I take away the |
Not quite sure what the |
the swiper take in a width and height parameter which can make it work in landscape, but it bugs out if a transition occurs. |
Hopefully this helps if someone comes across this issue. I used https://github.com/yamill/react-native-orientation to add an event when orientation changes. I then get the dimensions and change the state to those dimensions re-rendering screen. |
Thanks @joshualcoffee It sounds like the best solution may be to modify react-native-swiper to include react-native-orientation. |
@esutton You don't need to modify react-native-swiper directly. The Swiper component will listen for changes to the width prop so using react-native-orientation's orientation change event, you can pass the updated |
@joshualcoffee Could you please explain how did you do that? |
@cosivox Sure thing! This has not been tested but you should be able to get the idea from the example. This would be the internal slide component that you would include for each item in your slider. In my code I found setting the view to be absolute and setting left, right, top, and bottom to 0 achieved the result I wanted. import React, {Component} from 'react'
import Orientation from 'react-native-orientation'
const {
View,
Dimensions
} from 'react-native'
let window = Dimensions.get('window')
class Foo extend Component {
constructor(_){
super(_)
this._orientationDidChange = this._orientationDidChange.bind(this)
this.state = {
width: window.width,
height: window.height
}
}
_orientationDidChange(orientation) {
let window = Dimensions.get('window')
this.setState({
width: window.width,
height: window.height
})
}
componentDidMount() {
Orientation.addOrientationListener(this._orientationDidChange);
}
render(){
<View style={{width: this.state.width, height: this.state.height, position: 'absolute', left: 0, top:0, right: 0, bottom: 0}}>
}
} |
Setting |
@khrykin Does it working for you with vertical and horizontal mode? |
Does anyone know how to solve this problem ?
The text was updated successfully, but these errors were encountered: