Closed dongdyang closed 3 years ago
Yes you can see the MaonsryList Example. There is also Youtube
Hello @hyochan , thank u very much for ur awesome lib i wonder if i have dynamic height with the real image dimension instead of random height
@soly2014 I don't think this is the role of the library itself. However, I already tried this implementation on my side and I'll share this shortly. Hope it helps. However, when I applied the below, I realized that random height
looks much nicer so I've reverted it. Since most crawled
images have the dimension of 1:1
which is 1024x1024
.
getOriginalImageSize
function.export const getOriginalImageSize = async (
imageUri: string,
): Promise<ImageSize> =>
new Promise<ImageSize>((resolve, reject) =>
Image.getSize(
imageUri,
(width: number, height: number) =>
resolve({
width,
height,
}),
reject,
),
);
Get image aspectRatio
during rendering.
const [imgAspectRatio, setImgAspectRatio] = useState<number>(0);
const getImageRatio = useCallback(async (): Promise<void> => {
const imageSize = await getOriginalImageSize(imageURL);
if (imageSize) setImgAspectRatio(imageSize.height / imageSize.width);
}, [imageURL]);
useEffect(() => {
getImageRatio();
}, [getImageRatio]);
Put aspectRatio
to Image
.
<Image
progressiveRenderingEnabled
source={{uri: itemImageURL}}
resizeMode="cover"
style={{
alignSelf: 'stretch',
width: '100%',
aspectRatio: imgAspectRatio,
}}/>
@hyochan nice man how we can handle performance in case of large datasets ?? i mean virtualization
Is your feature request related to a problem? Please describe. A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
Describe the solution you'd like A clear and concise description of what you want to happen.
Describe alternatives you've considered A clear and concise description of any alternative solutions or features you've considered.
Additional context Add any other context or screenshots about the feature request here.