Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ If you love using React Native Awesome Gallery and would like to show your appre
- Fully customizable
- Both orientations (portrait + landscape)
- Infinite list
- Supports both iOS and Android.
- Supports iOS, Android, and Web.

## Installation

Expand Down
27 changes: 2 additions & 25 deletions example/src/screens/Photos.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,9 @@ import {
TouchableOpacity,
View,
} from 'react-native';
import AwesomeGallery, {
GalleryRef,
RenderItemInfo,
} from 'react-native-awesome-gallery';
import AwesomeGallery, { GalleryRef } from 'react-native-awesome-gallery';
import * as React from 'react';
import type { NavParams } from '../navigation/types';
import { Image } from 'expo-image';
import Animated, {
FadeInDown,
FadeInUp,
Expand All @@ -28,23 +24,6 @@ import Animated, {
} from 'react-native-reanimated';
import { useSafeAreaInsets } from 'react-native-safe-area-context';

const renderItem = ({
item,
setImageDimensions,
}: RenderItemInfo<{ uri: string }>) => {
return (
<Image
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

expo-image (at least this version) gives a bunch of errors on web, also the error in the main library was from defaultRenderImage, so switched to using that in the example

source={item.uri}
style={StyleSheet.absoluteFillObject}
contentFit="contain"
onLoad={(e) => {
const { width, height } = e.source;
setImageDimensions({ width, height });
}}
/>
);
};

export const Photos = () => {
const { top, bottom } = useSafeAreaInsets();
const { setParams, goBack } = useNavigation<
Expand Down Expand Up @@ -103,9 +82,7 @@ export const Photos = () => {
)}
<AwesomeGallery
ref={gallery}
data={params.images.map((uri) => ({ uri }))}
keyExtractor={(item) => item.uri}
renderItem={renderItem}
data={params.images}
initialIndex={params.index}
numToRender={3}
doubleTapInterval={150}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
"react-native-gesture-handler": "2.3.0",
"react-native-reanimated": "^3.2.0",
"release-it": "^14.2.2",
"typescript": "^4.1.3"
"typescript": "^4.9.5"
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

main was failing for yarn typescript with the old version

},
"peerDependencies": {
"react": "*",
Expand Down
18 changes: 14 additions & 4 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,19 @@ const defaultRenderImage = ({
}: RenderItemInfo<any>) => {
return (
<Image
onLoad={(e) => {
const { height: h, width: w } = e.nativeEvent.source;
setImageDimensions({ height: h, width: w });
onLoad={() => {
Image.getSize(
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nativeEvent.source doesn't work on web.

item,
(width, height) => {
setImageDimensions({
height,
width,
});
},
(err) => {
console.log('Image.getSize error', err);
}
);
}}
source={{ uri: item }}
resizeMode="contain"
Expand Down Expand Up @@ -786,7 +796,7 @@ const ResizableImage = React.memo(
.onEnd(({ x, y, numberOfPointers }) => {
'worklet';
if (!isActive.value) return;
if (numberOfPointers !== 1) return;
if (numberOfPointers > 1) return;
Copy link
Author

@markstreich markstreich Mar 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On web (with mouse), numberOfPointers is 0 (if I understand correctly, this was preventing two finger touches from triggering double clicks, so > 1 should have the same effect)

if (onTap && interruptedScroll.value) {
interruptedScroll.value = false;
if (onTap) {
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -9401,10 +9401,10 @@ typedarray@^0.0.6:
resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777"
integrity sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=

typescript@^4.1.3:
version "4.2.3"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.2.3.tgz#39062d8019912d43726298f09493d598048c1ce3"
integrity sha512-qOcYwxaByStAWrBf4x0fibwZvMRG+r4cQoTjbPtUlrWjBHbmCAww1i448U0GJ+3cNNEtebDteo/cHOR3xJ4wEw==
typescript@^4.9.5:
version "4.9.5"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.9.5.tgz#095979f9bcc0d09da324d58d03ce8f8374cbe65a"
integrity sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==

ua-parser-js@^0.7.18:
version "0.7.24"
Expand Down