question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Extra height is added below Carousel.

See original GitHub issue

Is this a bug report, a feature request, or a question?

Question.

Have you made sure that it wasn’t a React Native bug?

Yes

Is the bug specific to iOS or Android? Or can it be reproduced on both platforms?

Both platforms.

Is the bug reproductible in a production environment (not a debug one)?

Yes

Environment

Expo: 32 (latest)
React: 16.5
React native: 0.58
react-native-snap-carousel: 3.7.5 (latest)

Target Platform: Android (6.0) iOS (10.3)

Expected Behavior

I use a vertical Flatlist to show some users. Each list item has a Carousel component. The images in it should be at the appropriate height, like this:

screenshot 2019-03-05 at 01 34 06

Actual Behavior

Instead, extra height (from padding/margin maybe?) are added:

screenshot 2019-03-05 at 01 28 46

Notice that the below user’s photo is visible, which clearly shouldn’t be, giving me the impression that the images are placed in an absolute way or something (not sure if this matter)

I thought this has something to with the Pagination component (which I don’t use) but then again extra height is added on top of it, so it should be a problem with the Carousel itself.

My code:

<Carousel
              ref={(c) => { this._carousel = c; }}
              data={this.props.item.images}
              renderItem={this._renderItem}
              inactiveSlideScale={1}
              inactiveSlideOpacity={1}
              layoutCardOffset={0}
              callbackOffsetMargin={6} // default is 5
              sliderWidth={windowWidth*0.9}
              // sliderHeight={windowWidth*0.9}
              itemWidth={windowWidth*0.9}
              // itemHeight={windowWidth*0.9}
              showsHorizontalScrollIndicator={false}
              // style={{ width: windowWidth*0.9,  borderRadius: 10, overflow: 'hidden'}}
              onBeforeSnapToItem={(index) => {
                console.log('got called')
              }}
            />
_renderItem ({item, index}) {
      return (
        <Image source={{ uri: "http://res.cloudinary.com/blabla/image/upload/" + item }} style={{ width: windowWidth*0.9, height: windowWidth*0.9 }} />
      );
    }

PS: Let me know if a Snack is needed here, although there is pretty nothing other relevant to show I think.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

38reactions
gicommented, Apr 23, 2019

@spyshower Try setting the Carousel prop containerCustomStyle.flexGrow to 0:

<Carousel
  {/* ... */}
   containerCustomStyle={{
    flexGrow: 0,
  }}
  {/* ... */}
/>

I had a similar issue when rendering a Pagination component below the carousel, where there was lots of excess space between the two components.

23reactions
anon-r-7commented, Apr 7, 2019

The issue is a result of implementation of the <Pagination /> element. This element defines a style for paddingVertical: 30. This style can be overridden by the received prop containerStyle. So to solve:

<Pagination
  containerStyle={{paddingVertical: 0}}
/>
Read more comments on GitHub >

github_iconTop Results From Across the Web

Extra height is added below Carousel. · Issue #489 - GitHub
Actual Behavior. I thought this has something to with the Pagination component (which I don't use) but then again extra height is added...
Read more >
Setting a max-height on a Bootstrap Carousel - Stack Overflow
The idea is that any images which are too tall will appear with black bars to the left and right so it maintains...
Read more >
Consistent Height Carousels with CSS Gradients and Object Fit
The best way to do it is to add the gradient on top of the image, but behind the caption, so you can...
Read more >
Bootstrap 4 Blueprints Edit And Change Carousel Height
Bootstrap 4 Blueprints Edit And Change Carousel Height . Bootstrap 4 Blueprints Rapid Page Creation Tool. Bootstrap 4 is an awesome platform ...
Read more >
How To Resize The Carousel From The New Templates
Extra: Carousel Generator Tool​​ Enter a width and height for the carousel, then press the Generate CSS Code button. The tool will automatically...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found