Comments (10)
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.
from react-native-swiper.
@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 Dimensions.get('window').width
.
from react-native-swiper.
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 Swiper
element, the content expands as expected. Any ideas? Wonder if this is related to the fact that this is interpreted/rendered as an <index>
element rather than Swiper
or some other expected element...
from react-native-swiper.
Not quite sure what the automaticallyAdjustContentInsets
property does per the docs, I tried setting this to true
thinking it might affect layout but no luck.
from react-native-swiper.
the swiper take in a width and height parameter which can make it work in landscape, but it bugs out if a transition occurs.
from react-native-swiper.
Thanks @joshualcoffee
It sounds like the best solution may be to modify react-native-swiper to include react-native-orientation.
https://github.com/yamill/react-native-orientation
from react-native-swiper.
@joshualcoffee Could you please explain how did you do that?
from react-native-swiper.
@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}}>
}
}
from react-native-swiper.
Setting width
prop to Dimensions.get('window').width
solved problem for me
from react-native-swiper.
@khrykin Does it working for you with vertical and horizontal mode?
Could you send your code?
from react-native-swiper.
Related Issues (20)
- Data is not displayed correctly when the data is changed
- Is this still maintained? Or EOL? HOT 5
- how to prevent user to not come on first screen after the last swipe?
- how to detect swipe left or right HOT 1
- ViewPropTypes will be removed from React Native. Migrate to ViewPropTypes exported from 'deprecated-react-native-prop-types HOT 4
- how to swipe to next screen when user press the button HOT 1
- 好像停更了?
- flicker in the area of <Swiper> Component when swiping on the latest version of react-native HOT 4
- Position: aboslute won't make button clickable
- In the case of iPhone, touch is not available when using Flatlist items.
- Invariant Violation: ViewPropTypes has been removed from React Native. Migrate to ViewPropTypes exported from 'deprecated-react-native-prop-types' HOT 1
- OnIndexChanged
- Just don't use this lib. HOT 3
- [All-iPhone-Device] Two photos are displayed in one picture in the Swiper HOT 1
- Add animation to update pagination dot while swiping HOT 2
- Warning: Failed prop type: The prop `children` is marked as required in `_default`, but its value is `undefined`.
- index value will be out of reange after updating the UseState
- How can we make screen transitions by touching dots? How can I add a background to the dots?
- How to adjust spacing of pagination dots ?
- onIndexChanged getting wrong value
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-native-swiper.