React-native-fast-image: When resizeMode.contain is it possible not "center" the image?

Created on 13 Jun 2019  路  4Comments  路  Source: DylanVann/react-native-fast-image

Describe the bug
I'm not sure if this is a bug, but following the code and image bellow, I notice that there's always a white space between the image, like the image it's been centered some how. I tried flex alignments but noting seems to work.

Using resizeMode.contain I got the white spaces; using resizeMode.cover I loose a little of the width.

The white space increase as the image gets taller (huge height).

To Reproduce
Follow the code:

<FastImage
    style={{ flex: 1 }}
    source={{
        priority: FastImage.priority.normal,
        uri: this.props.src
    }}
    resizeMode={this.props.resizeMode || FastImage.resizeMode.contain}
/>

Expected behavior
The image should not have those white spaces at top and bottom of the element <FastImage.

Screenshots
Imgur

Dependency versions

  • React Native version: 0.59.9
  • React version: 16.8.3
  • React Native Fast Image version: 6.0.3

Note: if these are not the latest versions of each I recommend updating as extra effort will not be taken to be backwards compatible, and updating might resolving your issue.

bug

All 4 comments

I think you need to assign width and height to your image

Like this?

const style: any = {
      backgroundColor: 'red',
      flex: 1,
      height: this.props.height,
      width: this.props.width,
    };

Nothing changes.

I believe that StyleSheet.absoluteFill it's centering the image

Hey @rochapablo did you end up solving this?

Was this page helpful?
0 / 5 - 0 ratings