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

Issue with customizing border in imageStyle when resizeMode is "contain" or "center" #56

Open
MrSinaRJ opened this issue Jul 7, 2022 · 4 comments

Comments

@MrSinaRJ
Copy link

MrSinaRJ commented Jul 7, 2022

I tried to add a radius to each image in imageStyle, but the photos will change behavior strangely due to some behind the scene work that I couldn't find.
I will post both code and screenshot of the standard format and what I want to achieve that gave me a headache for two days 😁
I hope it's something easy to fix.

import { StatusBar } from "expo-status-bar";
import { StyleSheet, Text, View } from "react-native";
import {
  DynamicCollage,
  StaticCollage,
} from "@qeepsake/react-native-images-collage";

export default function App() {
  const photos = [
    "https://picsum.photos/300/600",
    "https://picsum.photos/300/500",
    "https://picsum.photos/300/400",
    "https://picsum.photos/300/700",
    "https://picsum.photos/300/800",
    "https://picsum.photos/300/600",
    "https://picsum.photos/300/500",
    "https://picsum.photos/300/400",
    "https://picsum.photos/300/700",
    "https://picsum.photos/300/800",
  ];
  return (
    <View style={styles.container}>
      <StatusBar style="auto" />
      <StaticCollage
        images={photos}
        matrix={[1, 1, 2, 1, 2, 1, 2]}
        direction="column"
        imageStyle={{
          margin: 5,
          resizeMode: "contain",
        }}
        containerStyle={styles.container}
      />
    </View>
  );
}

const styles = StyleSheet.create({
  container: {
    backgroundColor: "#fff",
    borderRadius: 0,
    flex: 1,
  },
});

WhatsApp Image 2022-07-07 at 1 48 21 PM

import { StatusBar } from "expo-status-bar";
import { StyleSheet, Text, View } from "react-native";
import {
  DynamicCollage,
  StaticCollage,
} from "@qeepsake/react-native-images-collage";

export default function App() {
  const photos = [
    "https://picsum.photos/300/600",
    "https://picsum.photos/300/500",
    "https://picsum.photos/300/400",
    "https://picsum.photos/300/700",
    "https://picsum.photos/300/800",
    "https://picsum.photos/300/600",
    "https://picsum.photos/300/500",
    "https://picsum.photos/300/400",
    "https://picsum.photos/300/700",
    "https://picsum.photos/300/800",
  ];
  return (
    <View style={styles.container}>
      <StatusBar style="auto" />
      <StaticCollage
        images={photos}
        matrix={[1, 1, 2, 1, 2, 1, 2]}
        direction="column"
        imageStyle={{
          borderRadius: 5,
          margin: 5,
          resizeMode: "contain",
        }}
        containerStyle={styles.container}
      />
    </View>
  );
}

const styles = StyleSheet.create({
  container: {
    backgroundColor: "#fff",
    borderRadius: 0,
    flex: 1,
  },
});

WhatsApp Image 2022-07-07 at 1 48 21 PM (1)

EDIT: I forgot to mention, this only happens if the resizeMode is set to contain or center in imageStyle

@MrSinaRJ
Copy link
Author

MrSinaRJ commented Jul 7, 2022

More on this matter:

If I do anything related to borders, it will destroy the result and make it unusable.
adding the borderWidth: 1 will break as same as borderRadius: 5

@MrSinaRJ MrSinaRJ changed the title Issue with borderRadius in imageStyle Issue with customizing border in imageStyle when resizeMode is "contain" or "center" Jul 7, 2022
@lukebrandonfarrell
Copy link
Contributor

lukebrandonfarrell commented Jul 7, 2022

Hey @MrSinaRJ, I'm not fully understanding the problem. Are you saying that when you set resizeMode to contain it creates a blur effect on the borders?

Screenshot 2022-07-07 at 13 52 02

@MrSinaRJ
Copy link
Author

MrSinaRJ commented Jul 7, 2022

Hey @lukebrandonfarrell,
yes, you can get this effect with either of 2 settings below:

resizeMode: "contain",
borderWidth: 1

OR

resizeMode: "contain",
borderRadius: 5

Also, you can replace contain with center.
When the photo is smaller than the frame, it will stretch to the end

@lukebrandonfarrell
Copy link
Contributor

Hmm that is very strange 🤔 I've never seen behaviour like that before

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

2 participants