react-native-gesture-image-viewer 1.6.1 → 1.6.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -2,478 +2,85 @@
2
2
 
3
3
  > English | [한국어](./README-ko_kr.md)
4
4
 
5
+ <div align="center">
6
+ <img src="./assets/logo.png" width="300px" alt="React Native Gesture Image Viewer logo" />
7
+ </div>
8
+
5
9
  ## Overview
6
10
 
7
11
  Have you ever struggled with implementing complex gesture handling and animations when building image galleries or content viewers in React Native?
8
12
 
9
13
  Existing libraries often have limited customization options or performance issues. `react-native-gesture-image-viewer` is a high-performance **universal gesture viewer** library built on React Native Reanimated and Gesture Handler, providing complete customization and intuitive gesture support for not only images but also videos, custom components, and any other content.
10
14
 
11
- ### Key Features
12
-
13
- - ✅ **Complete Gesture Support** - Pinch zoom, double-tap zoom, swipe navigation, vertical drag dismiss
14
- - ✅ **High-Performance Animations** - Smooth 60fps animations powered by React Native Reanimated
15
- - ✅ **Full Customization** - Complete control over components, styles, and behaviors
16
- - ✅ **External Control API** - Programmatic control from buttons or other components
17
- - ✅ **Multi-Instance Management** - ID-based independent management of multiple viewers
18
- - ✅ **Flexible Integration** - Use with Modal, [React Native Modal](https://www.npmjs.com/package/react-native-modal), ScrollView, FlatList, [FlashList](https://www.npmjs.com/package/@shopify/flash-list), [Expo Image](https://www.npmjs.com/package/expo-image), [FastImage](https://github.com/DylanVann/react-native-fast-image), and more
19
- - ✅ **Full TypeScript Support** - Enhanced developer experience with smart type inference
20
- - ✅ **Cross-Platform** - iOS, Android, and Web support
21
- - ✅ **Easy-to-Use API** - Intuitive and simple implementation without complex setup
22
- - ✅ **Various Environment Support** - Expo Go and New Architecture support
23
-
24
- ## Quick Start
25
-
26
- ### Examples & Demo
27
- - [📁 Example Project](/example/) - Real implementation code with various use cases
28
- - [🤖 Expo Go](https://snack.expo.dev/@harang/react-native-gesture-image-viewer) - Try it instantly on Snack Expo
29
-
30
15
  <p align="center">
31
- <img src="./assets/example.gif" width="600" />
16
+ <img src="./assets/example.gif" width="600" alt="Gesture and zoom demo" />
32
17
  </p>
33
18
 
34
- ### Prerequisites
35
-
36
- > [!IMPORTANT]
37
- > `react-native-gesture-image-viewer` is a high-performance viewer library built on [`react-native-reanimated`](https://www.npmjs.com/package/react-native-reanimated) and [`react-native-gesture-handler`](https://www.npmjs.com/package/react-native-gesture-handler).
38
- > Therefore, you must install React Native Reanimated and Gesture Handler before using this library. Please refer to the official documentation of these libraries for detailed setup guides.
39
-
40
- ```bash
41
- npm install react-native-reanimated
42
- npm install react-native-gesture-handler
43
- ```
44
-
45
- #### Minimum Requirements
46
-
47
- |Library|Minimum Version|
48
- |:--|:--:|
49
- |`react`|`>=18.0.0`|
50
- |`react-native`|`>=0.75.0`|
51
- |`react-native-gesture-handler`|`>=2.24.0`|
52
- |`react-native-reanimated`|`>=3.0.0`|
53
-
54
- #### [React Native Reanimated Setup](https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/getting-started/)
55
-
56
- Add the plugin to your `babel.config.js`:
57
-
58
- ```js
59
- // babel.config.js
60
- module.exports = {
61
- presets: [
62
- ... // don't add it here :)
63
- ],
64
- plugins: [
65
- ...
66
- // for web
67
- '@babel/plugin-proposal-export-namespace-from',
68
- // react-native-reanimated/plugin has to be listed last.
69
- 'react-native-reanimated/plugin',
70
- ],
71
- };
72
- ```
73
-
74
- Wrap your Metro config with `wrapWithReanimatedMetroConfig` in `metro.config.js`:
75
-
76
- ```js
77
- const {
78
- wrapWithReanimatedMetroConfig,
79
- } = require('react-native-reanimated/metro-config');
80
-
81
- const config = {
82
- // Your existing Metro configuration options
83
- };
84
-
85
- module.exports = wrapWithReanimatedMetroConfig(config);
86
- ```
87
-
88
- #### [react-native-gesture-handler Setup](https://docs.swmansion.com/react-native-gesture-handler/docs/fundamentals/installation)
89
-
90
- - `react-native-gesture-handler` generally doesn't require additional setup, but please refer to the official documentation for your specific environment.
91
- - For [using gestures in Android modals](https://docs.swmansion.com/react-native-gesture-handler/docs/fundamentals/installation#android), you would normally need to wrap modal content with `GestureHandlerRootView`. However, this library already includes `GestureHandlerRootView` internally, so no additional wrapping is needed when using modals.
19
+ ### Key Features
92
20
 
93
- ### Installation
21
+ - 🤌 **Complete Gesture Support** - Pinch zoom, double-tap zoom, swipe navigation, pan when zoomed-in, and vertical drag to dismiss
22
+ - 🏎️ **High-Performance Animations** - Smooth and responsive animations at 60fps and beyond, powered by React Native Reanimated
23
+ - 🎨 **Full Customization** - Total control over components, styles, and gesture behavior
24
+ - 🎛️ **External Control API** - Trigger actions programmatically from buttons or other UI components
25
+ - 🧩 **Multi-Instance Management** - Manage multiple viewers independently using unique IDs
26
+ - 🧬 **Flexible Integration** - Use with Modal, [React Native Modal](https://www.npmjs.com/package/react-native-modal), ScrollView, FlatList, [FlashList](https://www.npmjs.com/package/@shopify/flash-list), [Expo Image](https://www.npmjs.com/package/expo-image), [FastImage](https://github.com/DylanVann/react-native-fast-image), and more
27
+ - 🧠 **Full TypeScript Support** - Great developer experience with type inference and safety
28
+ - 🌐 **Cross-Platform** - Runs on iOS, Android, and Web with Expo Go and New Architecture compatibility
29
+ - 🪄 **Easy-to-Use API** - Simple and intuitive API that requires minimal setup
94
30
 
95
- ```bash
96
- # npm
97
- npm install react-native-gesture-image-viewer
31
+ ## Quick Start
98
32
 
99
- # pnpm
100
- pnpm add react-native-gesture-image-viewer
33
+ ### 📚 Documentation
101
34
 
102
- # yarn
103
- yarn add react-native-gesture-image-viewer
35
+ Full documentation is available at: <https://react-native-gesture-image-viewer.pages.dev>
104
36
 
105
- # bun
106
- bun add react-native-gesture-image-viewer
107
- ```
37
+ ### Examples & Demo
108
38
 
109
- ## Usage
39
+ - [📁 Example Project](/example/) - Real implementation code with various use cases
40
+ - [🤖 Expo Go](https://snack.expo.dev/@harang/react-native-gesture-image-viewer) - Try it instantly on Snack Expo
110
41
 
111
42
  ### Basic Usage
112
43
 
113
44
  `react-native-gesture-image-viewer` is a library focused purely on gesture interactions for complete customization.
114
- You can create a viewer using any `Modal` of your choice as shown below:
115
45
 
116
46
  ```tsx
117
- import { FlatList, Image, Modal } from 'react-native';
118
- import { GestureViewer } from 'react-native-gesture-image-viewer';
47
+ import { useCallback, useState } from 'react';
48
+ import { ScrollView, Image, Modal, View, Text, Button } from 'react-native';
49
+ import { GestureViewer, useGestureViewerController, useGestureViewerEvent } from 'react-native-gesture-image-viewer';
119
50
 
120
51
  function App() {
121
52
  const images = [...];
122
53
  const [visible, setVisible] = useState(false);
123
54
 
124
- // Wrap with useCallback for performance optimization
55
+ const { goToIndex, goToPrevious, goToNext, currentIndex, totalCount } = useGestureViewerController();
56
+
125
57
  const renderImage = useCallback((imageUrl: string) => {
126
58
  return <Image source={{ uri: imageUrl }} style={{ width: '100%', height: '100%' }} resizeMode="contain" />;
127
59
  }, []);
128
60
 
61
+ useGestureViewerEvent('zoomChange', (data) => {
62
+ console.log(`Zoom changed from ${data.previousScale} to ${data.scale}`);
63
+ });
64
+
129
65
  return (
130
66
  <Modal visible={visible} onRequestClose={() => setVisible(false)}>
131
67
  <GestureViewer
132
68
  data={images}
133
69
  renderItem={renderImage}
134
- ListComponent={FlatList}
70
+ ListComponent={ScrollView}
135
71
  onDismiss={() => setVisible(false)}
136
72
  />
137
- </Modal>
138
- );
139
- }
140
- ```
141
-
142
- ### Gesture Features
143
-
144
- `react-native-gesture-image-viewer` supports various gestures essential for viewers. All gestures are enabled by default.
145
-
146
- ```tsx
147
- function App() {
148
- return (
149
- <GestureViewer
150
- data={images}
151
- renderItem={renderImage}
152
- enableLoop={false}
153
- enableDismissGesture
154
- enableSwipeGesture
155
- enableZoomGesture
156
- enableDoubleTapGesture
157
- enableZoomPanGesture
158
- />
159
- )
160
- }
161
- ```
162
-
163
- |Property|Description|Default|
164
- |:--:|:-----|:--:|
165
- |`enableLoop`|Enables loop mode. When `true`, navigating next from the last item goes to the first item, and navigating previous from the first item goes to the last item.|`false`|
166
- |`enableDismissGesture`|Calls `onDismiss` function when swiping down. Useful for closing modals with downward swipe gestures.|`true`|
167
- |`enableSwipeGesture`|Controls left/right swipe gestures. When `false`, horizontal gestures are disabled.|`true`|
168
- |`enableZoomGesture`|Controls two-finger pinch gestures with focal point zooming. When `false`, pinch zoom is disabled. Zoom centers on the point between your two fingers for intuitive scaling.|`true`|
169
- |`enableDoubleTapGesture`|Controls double-tap zoom gestures with precision targeting. When `false`, double-tap zoom is disabled. Zoom centers exactly on the tapped location.|`true`|
170
- |`enableZoomPanGesture`|Enables panning when zoomed in with automatic boundary detection. When `false`, movement is disabled during zoom. Prevents content from moving outside visible screen area.|`true`|
171
-
172
- ### Custom Components
173
-
174
- `react-native-gesture-image-viewer` offers powerful complete component customization. You can create gesture-supported items with not only images but any component you want.
175
-
176
- #### List Components
177
-
178
- Support for any list component like `ScrollView`, `FlatList`, `FlashList` through the `ListComponent` prop.
179
- The `listProps` provides **type inference based on the selected list component**, ensuring accurate autocompletion and type safety in your IDE.
180
-
181
- ```tsx
182
- import { FlashList } from '@shopify/flash-list';
183
-
184
- function App() {
185
- return (
186
- <GestureViewer
187
- data={images}
188
- ListComponent={FlashList}
189
- listProps={{
190
- // ✅ FlashList props autocompletion
191
- }}
192
- />
193
- );
194
- }
195
- ```
196
-
197
- #### Content Components
198
-
199
- You can inject various types of content components like `expo-image`, `FastImage`, etc., through the `renderItem` prop to use gestures.
200
-
201
- ```tsx
202
- import { GestureViewer } from 'react-native-gesture-image-viewer';
203
- import { Image } from 'expo-image';
204
-
205
- function App() {
206
- const renderImage = useCallback((imageUrl: string) => {
207
- return <Image source={{ uri: imageUrl }} style={{ width: '100%', height: '100%' }} contentFit="contain" />;
208
- }, []);
209
-
210
- return (
211
- <GestureViewer
212
- data={images}
213
- renderItem={renderImage}
214
- />
215
- );
216
- }
217
- ```
218
-
219
- ### useGestureViewerController
220
-
221
- You can programmatically control the `GestureViewer` using the `useGestureViewerController` hook.
222
-
223
- ```tsx
224
- import { GestureViewer, useGestureViewerController } from 'react-native-gesture-image-viewer';
225
-
226
- function App() {
227
- const {
228
- goToIndex,
229
- goToPrevious,
230
- goToNext,
231
- currentIndex,
232
- totalCount,
233
- zoomIn,
234
- zoomOut,
235
- resetZoom,
236
- rotate
237
- } = useGestureViewerController();
238
-
239
- return (
240
- <View>
241
- <GestureViewer
242
- data={images}
243
- renderItem={renderImage}
244
- />
245
- {/* Zoom Controls */}
246
- <View>
247
- <Feather.Button name="zoom-in" onPress={() => zoomIn(0.25)} />
248
- <Feather.Button name="zoom-out" onPress={() => zoomOut(0.25)} />
249
- <Feather.Button
250
- name="refresh-cw"
251
- onPress={() => {
252
- rotate(0);
253
- resetZoom();
254
- }}
255
- />
256
- <Feather.Button name="rotate-cw" onPress={() => rotate(90)} />
257
- <Feather.Button name="rotate-ccw" onPress={() => rotate(90, false)} />
258
- </View>
259
- {/* Navigation Controls */}
260
73
  <View>
261
- <Feather.Button name="chevron-left" onPress={goToPrevious} />
74
+ <Button title="<" onPress={goToPrevious} />
262
75
  <Button title="Jump to index 2" onPress={() => goToIndex(2)} />
263
- <Feather.Button name="chevron-right" onPress={goToNext} />
76
+ <Button title=">" onPress={goToNext} />
264
77
  <Text>{`${currentIndex + 1} / ${totalCount}`}</Text>
265
78
  </View>
266
- </View>
267
- );
268
- }
269
- ```
270
-
271
- #### API Reference
272
-
273
- | Property | Description | Type | Default |
274
- |:---------|:------------|:-----|:-------:|
275
- | `goToIndex` | Navigate to a specific index. | `(index: number) => void` | - |
276
- | `goToPrevious` | Navigate to the previous item. | `() => void` | - |
277
- | `goToNext` | Navigate to the next item. | `() => void` | - |
278
- | `currentIndex` | The index of the currently displayed item. | `number` | `0` |
279
- | `totalCount` | The total number of items. | `number` | `0` |
280
- | `zoomIn` | Zoom in by the specified multiplier. | `(multiplier?: number) => void` | `0.25` |
281
- | `zoomOut` | Zoom out by the specified multiplier. | `(multiplier?: number) => void` | `0.25` |
282
- | `resetZoom` | Reset zoom to the specified scale. | `(scale?: number) => void` | `1` |
283
- | `rotate` | Rotate by the specified angle. | `(angle?: number, clockwise?: boolean) => void` | `90, true` |
284
-
285
- #### Parameters
286
-
287
- - `zoomIn(multiplier?)`
288
- - **multiplier**: The multiplier for zooming in (range: `0.01 ~ 1`)
289
- - Example: `zoomIn(0.5)` → Zoom in by an additional 50% of the current scale
290
- - `zoomOut(multiplier?)`
291
- - **multiplier**: The multiplier for zooming out (range: `0.01 ~ 1`)
292
- - Example: `zoomOut(0.3)` → Zoom out by dividing the current scale by 1.3
293
- - `resetZoom(scale?)`
294
- - **scale**: The scale value to reset to
295
- - Example: `resetZoom(1.5)` → Reset to 1.5x scale
296
- - `rotate(angle?, clockwise?)`
297
- - **angle**: The angle to rotate (0, 90, 180, 270, 360)
298
- - **clockwise**: The direction to rotate (true: clockwise, false: counter-clockwise)
299
- - Example: `rotate(90)` → Rotate 90 degrees clockwise
300
- - Example: `rotate(90, false)` → Rotate 90 degrees counter-clockwise
301
- - Example: `rotate(0)` → Reset rotation
302
-
303
- ### useGestureViewerEvent
304
-
305
- You can subscribe to specific events from `GestureViewer` using the `useGestureViewerEvent` hook. This allows you to respond to real-time gesture changes like zoom and rotation.
306
-
307
- ```tsx
308
- import { GestureViewer, useGestureViewerEvent } from 'react-native-gesture-image-viewer';
309
-
310
- function App() {
311
- // Listen to zoom changes on the default instance (ID: 'default')
312
- useGestureViewerEvent('zoomChange', (data) => {
313
- console.log(`Zoom changed from ${data.previousScale} to ${data.scale}`);
314
- });
315
-
316
- // Listen to rotation changes on the default instance (ID: 'default')
317
- useGestureViewerEvent('rotationChange', (data) => {
318
- console.log(`Rotation changed from ${data.previousRotation}° to ${data.rotation}°`);
319
- });
320
-
321
- // Listen to events on a specific instance
322
- useGestureViewerEvent('gallery', 'zoomChange', (data) => {
323
- console.log(`Gallery zoom: ${data.scale}x`);
324
- });
325
-
326
- return (
327
- <GestureViewer
328
- data={images}
329
- renderItem={renderImage}
330
- />
331
- );
332
- }
333
- ```
334
-
335
- #### Event Types
336
-
337
- | Event | Description | Data |
338
- |:-----|:-----|:-----|
339
- | `zoomChange` | Fired when the zoom scale changes during pinch gestures | `{ scale: number, previousScale: number }` |
340
- | `rotationChange` | Fired when the rotation angle changes during rotation gestures | `{ rotation: number, previousRotation: number }` |
341
-
342
- ### Style Customization
343
-
344
- You can customize the styling of `GestureViewer`.
345
-
346
- ```tsx
347
- import { GestureViewer } from 'react-native-gesture-image-viewer';
348
-
349
- function App() {
350
- return (
351
- <GestureViewer
352
- animateBackdrop={false}
353
- width={400}
354
- containerStyle={{ /* ... */ }}
355
- backdropStyle={{ backgroundColor: 'rgba(0, 0, 0, 0.90)' }}
356
- renderContainer={(children) => <View style={{ flex: 1 }}>{children}</View>}
357
- />
358
- );
359
- }
360
- ```
361
-
362
- |Property|Description|Default|
363
- |:--:|:-----|:--:|
364
- |`animateBackdrop`|By default, the background `opacity` gradually decreases from 1 to 0 during downward swipe gestures. When `false`, this animation is disabled.|`true`|
365
- |`width`|The width of content items. Default is window width.|`Dimensions width`|
366
- |`containerStyle`|Allows custom styling of the container that wraps the list component.|`flex: 1`|
367
- |`backdropStyle`|Allows customization of the viewer's background style.|`backgroundColor: black; StyleSheet.absoluteFill;`|
368
- |`renderContainer`|Allows custom wrapper component around `<GestureViewer />`.||
369
-
370
- ### Multi-Instance Management
371
-
372
- When you want to efficiently manage multiple `GestureViewer` instances, you can use the `id` prop to use multiple `GestureViewer` components.
373
- `GestureViewer` automatically removes instances from memory when components are unmounted, so no manual memory management is required.
374
-
375
- > The default `id` value is `default`.
376
-
377
- ```tsx
378
- import { GestureViewer, useGestureViewerController } from 'react-native-gesture-image-viewer';
379
-
380
- const firstViewerId = 'firstViewerId';
381
- const secondViewerId = 'secondViewerId';
382
-
383
- function App() {
384
- const { currentIndex: firstCurrentIndex, totalCount: firstTotalCount } = useGestureViewerController(firstViewerId);
385
- const { currentIndex: secondCurrentIndex, totalCount: secondTotalCount } = useGestureViewerController(secondViewerId);
386
-
387
- return (
388
- <View>
389
- <GestureViewer
390
- id={firstViewerId}
391
- data={images}
392
- renderItem={renderImage}
393
- />
394
- <GestureViewer
395
- id={secondViewerId}
396
- data={images}
397
- renderItem={renderImage}
398
- />
399
- </View>
400
- );
401
- }
402
- ```
403
-
404
- ### Additional Props
405
-
406
- #### `onIndexChange`
407
- The `onIndexChange` callback function is called when the `index` value changes.
408
-
409
- ```tsx
410
- import { GestureViewer } from 'react-native-gesture-image-viewer';
411
-
412
- function App() {
413
- const [currentIndex, setCurrentIndex] = useState(0);
414
-
415
- return (
416
- <GestureViewer
417
- onIndexChange={setCurrentIndex}
418
- />
419
- );
420
- }
421
- ```
422
-
423
- #### `useSnap`
424
- Sets the scroll behavior mode. `false` (default) uses paging mode, `true` uses snap mode.
425
-
426
- ```tsx
427
- import { GestureViewer } from 'react-native-gesture-image-viewer';
428
-
429
- function App() {
430
- return (
431
- <GestureViewer
432
- data={data}
433
- renderItem={renderItem}
434
- useSnap={true}
435
- />
436
- );
437
- }
438
- ```
439
-
440
- #### `itemSpacing`
441
- Sets the spacing between items in pixels. Only applied when `useSnap` is `true`.
442
-
443
- ```tsx
444
- import { GestureViewer } from 'react-native-gesture-image-viewer';
445
-
446
- function App() {
447
- return (
448
- <GestureViewer
449
- data={data}
450
- renderItem={renderItem}
451
- useSnap={true}
452
- itemSpacing={16} // 16px spacing between items
453
- />
79
+ </Modal>
454
80
  );
455
81
  }
456
82
  ```
457
83
 
458
- #### `initialIndex` (default: `0`)
459
- Sets the initial index value.
460
-
461
- #### `dismissThreshold` (default: `80`)
462
- `dismissThreshold` controls when `onDismiss` is called by applying a threshold value during vertical gestures.
463
-
464
- #### `resistance` (default: `2`)
465
- `resistance` controls the range of vertical movement by applying resistance during vertical gestures.
466
-
467
- #### `maxZoomScale` (default: `2`)
468
- Controls the maximum zoom scale multiplier.
469
-
470
- ## Performance Optimization Tips
471
-
472
- - Wrap the `renderItem` function with `useCallback` to prevent unnecessary re-renders.
473
- - For large images, we recommend using `FastImage` or `expo-image`.
474
- - For handling many images, we recommend using `FlashList`.
475
- - Test on actual devices (performance may be limited in simulators).
476
-
477
84
  ## Contributing
478
85
 
479
86
  For details on how to contribute to the project and set up the development environment, please refer to the [Contributing Guide](CONTRIBUTING.md).
@@ -35,9 +35,11 @@ export const useGestureViewer = ({
35
35
  const width = useSnap ? customWidth || screenWidth : screenWidth;
36
36
  const [isZoomed, setIsZoomed] = useState(false);
37
37
  const [isRotated, setIsRotated] = useState(false);
38
- const [currentIndex, setCurrentIndex] = useState(initialIndex);
39
38
  const [manager, setManager] = useState(null);
39
+ const listRef = useRef(null);
40
40
  const unsubscribeRef = useRef(null);
41
+ const onIndexChangeRef = useRef(null);
42
+ const lastEmittedIndexRef = useRef(null);
41
43
  const initialTranslateY = useSharedValue(0);
42
44
  const initialTranslateX = useSharedValue(0);
43
45
  const startScale = useSharedValue(1);
@@ -46,7 +48,6 @@ export const useGestureViewer = ({
46
48
  const scale = useSharedValue(1);
47
49
  const backdropOpacity = useSharedValue(1);
48
50
  const rotation = useSharedValue(0);
49
- const listRef = useRef(null);
50
51
  const dataLength = data?.length || 0;
51
52
  const adjustedInitialIndex = useMemo(() => {
52
53
  if (enableLoop && data.length > 1) {
@@ -80,19 +81,29 @@ export const useGestureViewer = ({
80
81
  }
81
82
  runOnJS(setIsRotated)(currentRotation % 360 !== 0);
82
83
  });
84
+ useEffect(() => {
85
+ onIndexChangeRef.current = onIndexChange ?? null;
86
+ });
87
+ useEffect(() => {
88
+ return () => {
89
+ onIndexChangeRef.current = null;
90
+ };
91
+ }, []);
83
92
  useEffect(() => {
84
93
  const handleManagerChange = manager => {
85
94
  unsubscribeRef.current?.();
86
95
  unsubscribeRef.current = null;
87
96
  setManager(manager);
97
+ lastEmittedIndexRef.current = null;
88
98
  if (manager) {
89
- setCurrentIndex(manager.getState().currentIndex);
90
99
  unsubscribeRef.current = manager.subscribe(state => {
91
- setCurrentIndex(state.currentIndex);
100
+ if (lastEmittedIndexRef.current !== state.currentIndex) {
101
+ lastEmittedIndexRef.current = state.currentIndex;
102
+ onIndexChangeRef.current?.(state.currentIndex);
103
+ }
92
104
  });
93
105
  return;
94
106
  }
95
- setCurrentIndex(0);
96
107
  };
97
108
  const unsubscribeFromRegistry = registry.subscribeToManager(id, handleManagerChange);
98
109
  return () => {
@@ -120,9 +131,6 @@ export const useGestureViewer = ({
120
131
  }
121
132
  manager.setListRef(listRef.current);
122
133
  }, [manager]);
123
- useEffect(() => {
124
- onIndexChange?.(currentIndex);
125
- }, [currentIndex, onIndexChange]);
126
134
  useEffect(() => {
127
135
  translateY.value = 0;
128
136
  translateX.value = 0;
@@ -158,10 +166,10 @@ export const useGestureViewer = ({
158
166
  if (needsJump && jumpToIndex !== undefined) {
159
167
  scrollTo(jumpToIndex, false);
160
168
  }
169
+ const currentIndex = manager?.getState() ?? 0;
161
170
  if (realIndex !== currentIndex && realIndex >= 0 && realIndex < dataLength) {
162
171
  if (manager) {
163
172
  manager.setCurrentIndex(realIndex);
164
- setCurrentIndex(realIndex);
165
173
  manager.notifyStateChange();
166
174
  }
167
175
  translateX.value = withTiming(0);
@@ -172,7 +180,7 @@ export const useGestureViewer = ({
172
180
  scale.value = withTiming(1);
173
181
  rotation.value = 0;
174
182
  }
175
- }, [scrollTo, manager, currentIndex, dataLength, width, itemSpacing, enableSwipeGesture, enableLoop, translateX, translateY, scale, initialTranslateX, initialTranslateY, startScale, rotation]);
183
+ }, [scrollTo, manager, dataLength, width, itemSpacing, enableSwipeGesture, enableLoop, translateX, translateY, scale, initialTranslateX, initialTranslateY, startScale, rotation]);
176
184
  const dismissGesture = useMemo(() => {
177
185
  return Gesture.Pan().minDistance(10).averageTouches(true).activeCursor('grabbing').activeOffsetY([-10, 10]).failOffsetX([-10, 10]).enabled(!isZoomed).onUpdate(event => {
178
186
  translateY.value = event.translationY / resistance;
@@ -342,7 +350,6 @@ export const useGestureViewer = ({
342
350
  manager?.handleScrollBeginDrag();
343
351
  }, [manager]);
344
352
  return {
345
- currentIndex,
346
353
  dataLength,
347
354
  translateY,
348
355
  listRef,
@@ -1 +1 @@
1
- {"version":3,"names":["useCallback","useEffect","useMemo","useRef","useState","InteractionManager","useWindowDimensions","Gesture","Easing","interpolate","runOnJS","useAnimatedReaction","useAnimatedStyle","useSharedValue","withSpring","withTiming","registry","createBoundsConstraint","createScrollAction","getLoopAdjustedIndex","useGestureViewer","data","initialIndex","onIndexChange","onDismiss","width","customWidth","dismissThreshold","resistance","animateBackdrop","enableDismissGesture","enableSwipeGesture","enableZoomGesture","enableDoubleTapGesture","enableZoomPanGesture","enableLoop","maxZoomScale","itemSpacing","useSnap","id","screenWidth","height","screenHeight","isZoomed","setIsZoomed","isRotated","setIsRotated","currentIndex","setCurrentIndex","manager","setManager","unsubscribeRef","initialTranslateY","initialTranslateX","startScale","translateY","translateX","scale","backdropOpacity","rotation","listRef","dataLength","length","adjustedInitialIndex","constrainTranslation","scrollTo","index","animated","scrollAction","current","emitZoomChange","currentScale","prevScale","emitRotationChange","currentRotation","prevRotation","value","previousScale","previousRotation","handleManagerChange","getState","subscribe","state","unsubscribeFromRegistry","subscribeToManager","setDataLength","setEnableSwipeGesture","setWidth","setHeight","setZoomSharedValues","setRotation","setEnableLoop","notifyStateChange","setListRef","runAfterInteractions","cancel","onMomentumScrollEnd","event","contentOffset","nativeEvent","scrollIndex","Math","round","x","isLoopHandled","handleMomentumScrollEnd","realIndex","needsJump","jumpToIndex","undefined","dismissGesture","Pan","minDistance","averageTouches","activeCursor","activeOffsetY","failOffsetX","enabled","onUpdate","translationY","onEnd","damping","stiffness","zoomPinchGesture","Pinch","onBegin","newScale","deltaScale","centerX","focalX","centerY","focalY","newTranslateX","newTranslateY","constrainedTranslateX","constrainedTranslateY","duration","easing","bezier","zoomPanGesture","translationX","doubleTapGesture","Tap","numberOfTaps","nextScale","y","zoomGesture","Race","Exclusive","animatedStyle","transform","rotate","backdropStyle","opacity","onScrollBeginDrag","handleScrollBeginDrag"],"sourceRoot":"../../src","sources":["useGestureViewer.ts"],"mappings":";;AAAA,SAASA,WAAW,E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AChC;QAAEpB,UAAU,EAAEA,UAAU,CAACoB;MAAM,CAAC,EAChC;QAAEnB,KAAK,EAAEA,KAAK,CAACmB;MAAM,CAAC,EACtB;QAAE2E,MAAM,EAAE,GAAG5F,QAAQ,CAACiB,KAAK;MAAM,CAAC;IAEtC,CAAC;EACH,CAAC,CAAC;EAEF,MAAM4E,aAAa,GAAG5I,gBAAgB,CAAC,MAAM;IAC3C,IAAI,CAACiB,eAAe,IAAI4B,KAAK,CAACmB,KAAK,KAAK,CAAC,EAAE;MACzC,OAAO;QAAE6E,OAAO,EAAE;MAAE,CAAC;IACvB;IAEA,MAAMA,OAAO,GAAGhJ,WAAW,CAAC8C,UAAU,CAACqB,KAAK,EAAE,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,OAAO,CAAC;IAExE,OAAO;MAAE6E;IAAQ,CAAC;EACpB,CAAC,EAAE,CAAC5H,eAAe,CAAC,CAAC;EAErB,MAAM6H,iBAAiB,GAAG1J,WAAW,CAAC,MAAM;IAC1CiD,OAAO,EAAE0G,qBAAqB,CAAC,CAAC;EAClC,CAAC,EAAE,CAAC1G,OAAO,CAAC,CAAC;EAEb,OAAO;IACLF,YAAY;IACZc,UAAU;IACVN,UAAU;IACVK,OAAO;IACPjB,QAAQ;IACRE,SAAS;IACTiE,cAAc;IACdoC,WAAW;IAEXlD,mBAAmB;IACnB0D,iBAAiB;IAEjBL,aAAa;IACbG;EACF,CAAC;AACH,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["useCallback","useEffect","useMemo","useRef","useState","InteractionManager","useWindowDimensions","Gesture","Easing","interpolate","runOnJS","useAnimatedReaction","useAnimatedStyle","useSharedValue","withSpring","withTiming","registry","createBoundsConstraint","createScrollAction","getLoopAdjustedIndex","useGestureViewer","data","initialIndex","onIndexChange","onDismiss","width","customWidth","dismissThreshold","resistance","animateBackdrop","enableDismissGesture","enableSwipeGesture","enableZoomGesture","enableDoubleTapGesture","enableZoomPanGesture","enableLoop","maxZoomScale","itemSpacing","useSnap","id","screenWidth","height","screenHeight","isZoomed","setIsZoomed","isRotated","setIsRotated","manager","setManager","listRef","unsubscribeRef","onIndexChangeRef","lastEmittedIndexRef","initialTranslateY","initialTranslateX","startScale","translateY","translateX","scale","backdropOpacity","rotation","dataLength","length","adjustedInitialIndex","constrainTranslation","scrollTo","index","animated","scrollAction","current","emitZoomChange","currentScale","prevScale","emitRotationChange","currentRotation","prevRotation","value","previousScale","previousRotation","handleManagerChange","subscribe","state","currentIndex","unsubscribeFromRegistry","subscribeToManager","setDataLength","setEnableSwipeGesture","setCurrentIndex","setWidth","setHeight","setZoomSharedValues","setRotation","setEnableLoop","notifyStateChange","setListRef","runAfterInteractions","cancel","onMomentumScrollEnd","event","contentOffset","nativeEvent","scrollIndex","Math","round","x","isLoopHandled","handleMomentumScrollEnd","realIndex","needsJump","jumpToIndex","undefined","getState","dismissGesture","Pan","minDistance","averageTouches","activeCursor","activeOffsetY","failOffsetX","enabled","onUpdate","translationY","onEnd","damping","stiffness","zoomPinchGesture","Pinch","onBegin","newScale","deltaScale","centerX","focalX","centerY","focalY","newTranslateX","newTranslateY","constrainedTranslateX","constrainedTranslateY","duration","easing","bezier","zoomPanGesture","translationX","doubleTapGesture","Tap","numberOfTaps","nextScale","y","zoomGesture","Race","Exclusive","animatedStyle","transform","rotate","backdropStyle","opacity","onScrollBeginDrag","handleScrollBeginDrag"],"sourceRoot":"../../src","sources":["useGestureViewer.ts"],"mappings":";;AAAA,SAASA,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,OAAO;AACzE,SACEC,kBAAkB,EAGlBC,mBAAmB,QACd,cAAc;AACrB,SAASC,OAAO,QAAQ,8BAA8B;AACtD,SACEC,MAAM,EACNC,WAAW,EACXC,OAAO,EACPC,mBAAmB,EACnBC,gBAAgB,EAChBC,cAAc,EACdC,UAAU,EACVC,UAAU,QACL,yBAAyB;AAEhC,S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,EAAEA,UAAU,CAACmB;MAAM,CAAC,EAChC;QAAElB,KAAK,EAAEA,KAAK,CAACkB;MAAM,CAAC,EACtB;QAAE6E,MAAM,EAAE,GAAG7F,QAAQ,CAACgB,KAAK;MAAM,CAAC;IAEtC,CAAC;EACH,CAAC,CAAC;EAEF,MAAM8E,aAAa,GAAG9I,gBAAgB,CAAC,MAAM;IAC3C,IAAI,CAACiB,eAAe,IAAI6B,KAAK,CAACkB,KAAK,KAAK,CAAC,EAAE;MACzC,OAAO;QAAE+E,OAAO,EAAE;MAAE,CAAC;IACvB;IAEA,MAAMA,OAAO,GAAGlJ,WAAW,CAAC+C,UAAU,CAACoB,KAAK,EAAE,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,OAAO,CAAC;IAExE,OAAO;MAAE+E;IAAQ,CAAC;EACpB,CAAC,EAAE,CAAC9H,eAAe,CAAC,CAAC;EAErB,MAAM+H,iBAAiB,GAAG5J,WAAW,CAAC,MAAM;IAC1C+C,OAAO,EAAE8G,qBAAqB,CAAC,CAAC;EAClC,CAAC,EAAE,CAAC9G,OAAO,CAAC,CAAC;EAEb,OAAO;IACLc,UAAU;IACVL,UAAU;IACVP,OAAO;IACPN,QAAQ;IACRE,SAAS;IACTmE,cAAc;IACdoC,WAAW;IAEXnD,mBAAmB;IACnB2D,iBAAiB;IAEjBL,aAAa;IACbG;EACF,CAAC;AACH,CAAC","ignoreList":[]}
@@ -2,7 +2,6 @@ import { type NativeScrollEvent, type NativeSyntheticEvent } from 'react-native'
2
2
  import type { GestureViewerProps } from './types';
3
3
  type UseGestureViewerProps<T = any> = Omit<GestureViewerProps<T>, 'renderItem' | 'renderContainer' | 'ListComponent' | 'listProps' | 'containerStyle' | 'backdropStyle'>;
4
4
  export declare const useGestureViewer: <T = any>({ data, initialIndex, onIndexChange, onDismiss, width: customWidth, dismissThreshold, resistance, animateBackdrop, enableDismissGesture, enableSwipeGesture, enableZoomGesture, enableDoubleTapGesture, enableZoomPanGesture, enableLoop, maxZoomScale, itemSpacing, useSnap, id, }: UseGestureViewerProps<T>) => {
5
- currentIndex: number;
6
5
  dataLength: number;
7
6
  translateY: import("react-native-reanimated").SharedValue<number>;
8
7
  listRef: import("react").RefObject<any>;
@@ -1 +1 @@
1
- {"version":3,"file":"useGestureViewer.d.ts","sourceRoot":"","sources":["../../../src/useGestureViewer.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,KAAK,iBAAiB,EACtB,KAAK,oBAAoB,EAE1B,MAAM,cAAc,CAAC;AActB,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAGlD,KAAK,qBAAqB,CAAC,CAAC,GAAG,GAAG,IAAI,IAAI,CACxC,kBAAkB,CAAC,CAAC,CAAC,EACrB,YAAY,GAAG,iBAAiB,GAAG,eAAe,GAAG,WAAW,GAAG,gBAAgB,GAAG,eAAe,CACtG,CAAC;AAEF,eAAO,MAAM,gBAAgB,GAAI,CAAC,GAAG,GAAG,EAAE,qRAqBvC,qBAAqB,CAAC,CAAC,CAAC;;;;;;;;;iCA6Kf,oBAAoB,CAAC,iBAAiB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+RlD,CAAC"}
1
+ {"version":3,"file":"useGestureViewer.d.ts","sourceRoot":"","sources":["../../../src/useGestureViewer.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,KAAK,iBAAiB,EACtB,KAAK,oBAAoB,EAE1B,MAAM,cAAc,CAAC;AActB,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAGlD,KAAK,qBAAqB,CAAC,CAAC,GAAG,GAAG,IAAI,IAAI,CACxC,kBAAkB,CAAC,CAAC,CAAC,EACrB,YAAY,GAAG,iBAAiB,GAAG,eAAe,GAAG,WAAW,GAAG,gBAAgB,GAAG,eAAe,CACtG,CAAC;AAEF,eAAO,MAAM,gBAAgB,GAAI,CAAC,GAAG,GAAG,EAAE,qRAqBvC,qBAAqB,CAAC,CAAC,CAAC;;;;;;;;iCAqLf,oBAAoB,CAAC,iBAAiB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8RlD,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-gesture-image-viewer",
3
- "version": "1.6.1",
3
+ "version": "1.6.3",
4
4
  "description": "🖼️ A highly customizable and easy-to-use React Native image viewer with gesture support and external controls",
5
5
  "main": "./lib/module/index.js",
6
6
  "types": "./lib/typescript/src/index.d.ts",
@@ -74,7 +74,7 @@
74
74
  "bugs": {
75
75
  "url": "https://github.com/saseungmin/react-native-gesture-image-viewer/issues"
76
76
  },
77
- "homepage": "https://github.com/saseungmin/react-native-gesture-image-viewer#readme",
77
+ "homepage": "https://react-native-gesture-image-viewer.pages.dev",
78
78
  "publishConfig": {
79
79
  "registry": "https://registry.npmjs.org/"
80
80
  },
@@ -106,7 +106,8 @@
106
106
  },
107
107
  "workspaces": [
108
108
  ".",
109
- "example"
109
+ "example",
110
+ "docs"
110
111
  ],
111
112
  "packageManager": "yarn@4.9.2",
112
113
  "jest": {
@@ -53,10 +53,12 @@ export const useGestureViewer = <T = any>({
53
53
 
54
54
  const [isZoomed, setIsZoomed] = useState(false);
55
55
  const [isRotated, setIsRotated] = useState(false);
56
- const [currentIndex, setCurrentIndex] = useState(initialIndex);
57
56
  const [manager, setManager] = useState<GestureViewerManager | null>(null);
58
57
 
58
+ const listRef = useRef<any>(null);
59
59
  const unsubscribeRef = useRef<(() => void) | null>(null);
60
+ const onIndexChangeRef = useRef<((index: number) => void) | null>(null);
61
+ const lastEmittedIndexRef = useRef<number>(null);
60
62
 
61
63
  const initialTranslateY = useSharedValue(0);
62
64
  const initialTranslateX = useSharedValue(0);
@@ -68,8 +70,6 @@ export const useGestureViewer = <T = any>({
68
70
  const backdropOpacity = useSharedValue(1);
69
71
  const rotation = useSharedValue(0);
70
72
 
71
- const listRef = useRef<any>(null);
72
-
73
73
  const dataLength = data?.length || 0;
74
74
 
75
75
  const adjustedInitialIndex = useMemo(() => {
@@ -130,6 +130,16 @@ export const useGestureViewer = <T = any>({
130
130
  },
131
131
  );
132
132
 
133
+ useEffect(() => {
134
+ onIndexChangeRef.current = onIndexChange ?? null;
135
+ });
136
+
137
+ useEffect(() => {
138
+ return () => {
139
+ onIndexChangeRef.current = null;
140
+ };
141
+ }, []);
142
+
133
143
  useEffect(() => {
134
144
  const handleManagerChange = (manager: GestureViewerManager | null) => {
135
145
  unsubscribeRef.current?.();
@@ -137,15 +147,17 @@ export const useGestureViewer = <T = any>({
137
147
 
138
148
  setManager(manager);
139
149
 
150
+ lastEmittedIndexRef.current = null;
151
+
140
152
  if (manager) {
141
- setCurrentIndex(manager.getState().currentIndex);
142
153
  unsubscribeRef.current = manager.subscribe((state) => {
143
- setCurrentIndex(state.currentIndex);
154
+ if (lastEmittedIndexRef.current !== state.currentIndex) {
155
+ lastEmittedIndexRef.current = state.currentIndex;
156
+ onIndexChangeRef.current?.(state.currentIndex);
157
+ }
144
158
  });
145
159
  return;
146
160
  }
147
-
148
- setCurrentIndex(0);
149
161
  };
150
162
 
151
163
  const unsubscribeFromRegistry = registry.subscribeToManager(id, handleManagerChange);
@@ -194,10 +206,6 @@ export const useGestureViewer = <T = any>({
194
206
  manager.setListRef(listRef.current);
195
207
  }, [manager]);
196
208
 
197
- useEffect(() => {
198
- onIndexChange?.(currentIndex);
199
- }, [currentIndex, onIndexChange]);
200
-
201
209
  useEffect(() => {
202
210
  translateY.value = 0;
203
211
  translateX.value = 0;
@@ -240,10 +248,11 @@ export const useGestureViewer = <T = any>({
240
248
  scrollTo(jumpToIndex, false);
241
249
  }
242
250
 
251
+ const currentIndex = manager?.getState() ?? 0;
252
+
243
253
  if (realIndex !== currentIndex && realIndex >= 0 && realIndex < dataLength) {
244
254
  if (manager) {
245
255
  manager.setCurrentIndex(realIndex);
246
- setCurrentIndex(realIndex);
247
256
  manager.notifyStateChange();
248
257
  }
249
258
 
@@ -259,7 +268,6 @@ export const useGestureViewer = <T = any>({
259
268
  [
260
269
  scrollTo,
261
270
  manager,
262
- currentIndex,
263
271
  dataLength,
264
272
  width,
265
273
  itemSpacing,
@@ -492,7 +500,6 @@ export const useGestureViewer = <T = any>({
492
500
  }, [manager]);
493
501
 
494
502
  return {
495
- currentIndex,
496
503
  dataLength,
497
504
  translateY,
498
505
  listRef,