Skip to content
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

Priority Balance doesn't work correctly with Portrait Images #116

Closed
phuchuynhStrong opened this issue Jun 15, 2019 · 1 comment
Closed

Comments

@phuchuynhStrong
Copy link
Contributor

phuchuynhStrong commented Jun 15, 2019

Expected Behavior

E9014035-94C9-4C8D-9FF4-78C12E3AB371

Current Behavior

IMG_3098 PNG

Possible Solution

  • In the _insertIntoColumn function, use scaled height instead of brick's image original height
  • In balance priority, the call to resolveBricks function in componentDidMount will be moved to setState function after setParentDimensions. Scaled height need column width to calculate so this change will make sure resolveBricks always get dimensions

Steps to Reproduce

  1. Add a Masonry into your View
  2. Use FastImage as your customImageComponent, priority balance
  3. Add some bricks with square and portrait images

Context (Environment)

react-native version 0.56.0
react-native-masonry version 0.5.0-alpha.4

Detailed Description

The code which I'm using

renderMasonry = sources => {
    let props = { onLoad: this.onLoad, data: sources, onError: this.onError };
    return (
      <View style={styles.masonryContainer}>
        <Masonry
          columns={2}
          spacing={MASONRY_ITEM_HORIZONTAL_GUT_SIZE}
          priority="balance"
          bricks={sources}
          customImageComponent={FastImage}
          imageContainerStyle={styles.masonryItemContainer}
          customImageProps={props}
        />
      </View>
    );
  };

Possible Implementation

I have open a pull-request for the fix. The link is #115

@phuchuynhStrong
Copy link
Contributor Author

Close it due to merged #115

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant