Wrong size (width and height) when embedded in other components
See original GitHub issueWhen <Swiper> is embedded into a component hierarchy, it will not fit in into the dimensions of the container. Both width and height are completely wrong and much to big.
Imagine the following screen:
- top bar
- container (flex: 4)
+ swiper embedded in container (flex: 4)
+ bottom bar of container (flex: 1)
- bottom bar (flex: 1)
This looks like this and you can see, that the swiper gots dimensions far away from the size of the container component.
I provided the whole code in a gist: https://gist.github.com/itinance/7d9c14f01bd0dd34008607f25c4391a7
When i set a specific height-attribute, everything works fine:
But to set a specific height destroys the flexibility of the whole flex based layout system.
Did i something wrong here?
This is the structure:
return (
<View style={{ flex: 1 }}>
<NavigationBar
style={ styles.navBar }
title={titleConfig}
rightButton={rightButtonConfig}
leftButton={leftButtonConfig}>
</NavigationBar>
<View style={styles.container}>
<View style={styles.topBox}>
</View>
<View style={styles.storyContainer}>
<View style={styles.storyImageContainer}>
<Swiper showsButtons={true} showsPagination={true} styles={styles.slider}>
<Image
style={styles.sliderImage}
source={{uri: 'https://upload.wikimedia.org/wikipedia/commons/f/fc/HGM_Raketengesch%C3%BCtz_1865.jpg'}}
/>
</Swiper>
</View>
<View style={styles.storyBox}>
</View>
</View>
</View>
</View>
);
The styles you will find at the bottom of my gist.
Issue Analytics
- State:
- Created 7 years ago
- Reactions:1
- Comments:10
Top Results From Across the Web
Adjust width and height of iframe to fit with content in it
The content inside the iframe is dynamic, so I had to readjust the width and height of the iframe itself. I use React...
Read more >Overflowing content - Learn web development | MDN
This box has a height and a width. This means that if there is too much content to be displayed within the assigned...
Read more >Setting Height And Width On Images Is Important Again
To prevent layout shifts and improve performance scores, we need to always set width and height attributes on our images.
Read more >CSS- Div- Be Careful When You Size Your Divs
It makes sense: both DIVs and tables can be nested, have HEIGHT and WIDTH attributes set, contain borders, etc. However, there is one...
Read more >How do you change the size of an embedded Google Doc?
Can you get at the HTML? You need to put a width and height on the <iframe>. <iframe width=600 height=500 src=.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’ve found a possible work around on application side:
I use state to manage the height of the swiper and change this height on the onLayout-Event of the parent container:
@jorfermo sorry, we’ve gave up here and switched in the end with all projects to https://github.com/zbtang/React-Native-ViewPager, where everything works fine from scratch.