react-native-gesture-image-viewer 1.6.0 → 1.6.2
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 +34 -427
- package/lib/module/GestureViewerManager.js +29 -21
- package/lib/module/GestureViewerManager.js.map +1 -1
- package/lib/module/useGestureViewer.js +5 -1
- package/lib/module/useGestureViewer.js.map +1 -1
- package/lib/typescript/src/GestureViewerManager.d.ts +8 -8
- package/lib/typescript/src/GestureViewerManager.d.ts.map +1 -1
- package/lib/typescript/src/useGestureViewer.d.ts.map +1 -1
- package/package.json +4 -3
- package/src/GestureViewerManager.ts +37 -25
- package/src/useGestureViewer.ts +7 -1
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
|
-
###
|
|
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
|
-
|
|
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
|
-
|
|
96
|
-
# npm
|
|
97
|
-
npm install react-native-gesture-image-viewer
|
|
31
|
+
## Quick Start
|
|
98
32
|
|
|
99
|
-
|
|
100
|
-
pnpm add react-native-gesture-image-viewer
|
|
33
|
+
### 📚 Documentation
|
|
101
34
|
|
|
102
|
-
|
|
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
|
-
|
|
106
|
-
bun add react-native-gesture-image-viewer
|
|
107
|
-
```
|
|
37
|
+
### Examples & Demo
|
|
108
38
|
|
|
109
|
-
|
|
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 {
|
|
118
|
-
import {
|
|
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
|
-
|
|
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={
|
|
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
|
-
<
|
|
74
|
+
<Button title="<" onPress={goToPrevious} />
|
|
262
75
|
<Button title="Jump to index 2" onPress={() => goToIndex(2)} />
|
|
263
|
-
<
|
|
76
|
+
<Button title=">" onPress={goToNext} />
|
|
264
77
|
<Text>{`${currentIndex + 1} / ${totalCount}`}</Text>
|
|
265
78
|
</View>
|
|
266
|
-
</
|
|
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).
|
|
@@ -7,18 +7,17 @@ class GestureViewerManager {
|
|
|
7
7
|
dataLength = 0;
|
|
8
8
|
width = 0;
|
|
9
9
|
height = 0;
|
|
10
|
-
scale = null;
|
|
11
|
-
translateX = null;
|
|
12
|
-
translateY = null;
|
|
13
10
|
maxZoomScale = 2;
|
|
14
|
-
listRef = null;
|
|
15
11
|
enableSwipeGesture = true;
|
|
16
12
|
enableLoop = false;
|
|
17
|
-
|
|
13
|
+
listRef = null;
|
|
14
|
+
scale = null;
|
|
18
15
|
rotation = null;
|
|
16
|
+
translateX = null;
|
|
17
|
+
translateY = null;
|
|
18
|
+
loopCallback = null;
|
|
19
|
+
listeners = new Set();
|
|
19
20
|
eventListeners = new Map();
|
|
20
|
-
animationTimeout = null;
|
|
21
|
-
static LOOP_ANIMATION_DURATION = 300;
|
|
22
21
|
notifyListeners() {
|
|
23
22
|
const state = this.getState();
|
|
24
23
|
this.listeners.forEach(listener => listener(state));
|
|
@@ -177,29 +176,30 @@ class GestureViewerManager {
|
|
|
177
176
|
if (!this.enableSwipeGesture || !this.listRef) {
|
|
178
177
|
return;
|
|
179
178
|
}
|
|
180
|
-
this.
|
|
179
|
+
this.loopCallback = null;
|
|
181
180
|
const {
|
|
182
181
|
scrollTo
|
|
183
182
|
} = createScrollAction(this.listRef, this.width);
|
|
184
183
|
if (this.enableLoop && this.dataLength > 1) {
|
|
185
184
|
if (index < 0) {
|
|
186
|
-
|
|
187
|
-
this.animationTimeout = setTimeout(() => {
|
|
185
|
+
this.loopCallback = () => {
|
|
188
186
|
scrollTo(this.dataLength, false);
|
|
189
187
|
this.updateCurrentIndex(this.dataLength - 1);
|
|
190
|
-
|
|
188
|
+
this.loopCallback = null;
|
|
189
|
+
};
|
|
190
|
+
scrollTo(0, true);
|
|
191
191
|
return;
|
|
192
192
|
}
|
|
193
193
|
if (index >= this.dataLength) {
|
|
194
|
-
|
|
195
|
-
this.animationTimeout = setTimeout(() => {
|
|
194
|
+
this.loopCallback = () => {
|
|
196
195
|
scrollTo(1, false);
|
|
197
196
|
this.updateCurrentIndex(0);
|
|
198
|
-
|
|
197
|
+
this.loopCallback = null;
|
|
198
|
+
};
|
|
199
|
+
scrollTo(this.dataLength + 1, true);
|
|
199
200
|
return;
|
|
200
201
|
}
|
|
201
|
-
|
|
202
|
-
scrollTo(scrollIndex, true);
|
|
202
|
+
scrollTo(index + 1, true);
|
|
203
203
|
this.updateCurrentIndex(index);
|
|
204
204
|
return;
|
|
205
205
|
}
|
|
@@ -209,11 +209,19 @@ class GestureViewerManager {
|
|
|
209
209
|
scrollTo(index, true);
|
|
210
210
|
this.updateCurrentIndex(index);
|
|
211
211
|
};
|
|
212
|
-
|
|
213
|
-
if (this.
|
|
214
|
-
|
|
215
|
-
this.animationTimeout = null;
|
|
212
|
+
handleMomentumScrollEnd = scrollIndex => {
|
|
213
|
+
if (!this.loopCallback) {
|
|
214
|
+
return false;
|
|
216
215
|
}
|
|
216
|
+
if (scrollIndex === 0 || scrollIndex === this.dataLength + 1) {
|
|
217
|
+
this.loopCallback();
|
|
218
|
+
return true;
|
|
219
|
+
}
|
|
220
|
+
this.loopCallback = null;
|
|
221
|
+
return true;
|
|
222
|
+
};
|
|
223
|
+
handleScrollBeginDrag = () => {
|
|
224
|
+
this.loopCallback = null;
|
|
217
225
|
};
|
|
218
226
|
goToPrevious = () => {
|
|
219
227
|
this.goToIndex(this.currentIndex - 1);
|
|
@@ -222,7 +230,7 @@ class GestureViewerManager {
|
|
|
222
230
|
this.goToIndex(this.currentIndex + 1);
|
|
223
231
|
};
|
|
224
232
|
cleanUp() {
|
|
225
|
-
this.
|
|
233
|
+
this.loopCallback = null;
|
|
226
234
|
this.listeners.clear();
|
|
227
235
|
this.listRef = null;
|
|
228
236
|
this.enableSwipeGesture = true;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["withTiming","createBoundsConstraint","createScrollAction","GestureViewerManager","currentIndex","dataLength","width","height","
|
|
1
|
+
{"version":3,"names":["withTiming","createBoundsConstraint","createScrollAction","GestureViewerManager","currentIndex","dataLength","width","height","maxZoomScale","enableSwipeGesture","enableLoop","listRef","scale","rotation","translateX","translateY","loopCallback","listeners","Set","eventListeners","Map","notifyListeners","state","getState","forEach","listener","subscribe","add","delete","addEventListener","eventType","callback","has","set","get","size","emitEvent","data","emitZoomChange","previousScale","emitRotationChange","previousRotation","totalCount","setEnableLoop","enabled","setWidth","setHeight","setListRef","ref","setDataLength","length","setEnableSwipeGesture","setCurrentIndex","index","setZoomSharedValues","notifyStateChange","setRotation","rotate","angle","clockwise","MAX_ANGLE","value","nextAngle","Math","floor","zoomIn","multiplier","nextScale","min","zoomOut","max","resetZoom","goToIndex","scrollTo","updateCurrentIndex","handleMomentumScrollEnd","scrollIndex","handleScrollBeginDrag","goToPrevious","goToNext","cleanUp","clear","targetIndex"],"sourceRoot":"../../src","sources":["GestureViewerManager.ts"],"mappings":";;AAAA,SAA2BA,UAAU,QAAQ,yBAAyB;AAOtE,SAASC,sBAAsB,EAAEC,kBAAkB,QAAQ,YAAS;AAEpE,MAAMC,oBAAoB,CAAC;EACjBC,YAAY,GAAG,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B,IAAI,CAACF,kBAAkB,GAAG,IAAI;IAC9B,IAAI,CAACL,YAAY,GAAG,CAAC;IACrB,IAAI,CAACC,UAAU,GAAG,CAAC;IACnB,IAAI,CAACG,YAAY,GAAG,CAAC;IACrB,IAAI,CAACI,KAAK,GAAG,IAAI;IACjB,IAAI,CAACE,UAAU,GAAG,IAAI;IACtB,IAAI,CAACC,UAAU,GAAG,IAAI;IACtB,IAAI,CAACF,QAAQ,GAAG,IAAI;IACpB,IAAI,CAACM,cAAc,CAAC8D,KAAK,CAAC,CAAC;EAC7B;EAEQP,kBAAkB,GAAIQ,WAAmB,IAAK;IACpD,IAAI,CAAC9E,YAAY,GAAG8E,WAAW;IAC/B,IAAI,CAAC7D,eAAe,CAAC,CAAC;EACxB,CAAC;AACH;AAEA,eAAelB,oBAAoB","ignoreList":[]}
|
|
@@ -146,6 +146,10 @@ export const useGestureViewer = ({
|
|
|
146
146
|
}
|
|
147
147
|
const contentOffset = event.nativeEvent.contentOffset;
|
|
148
148
|
const scrollIndex = Math.round(contentOffset.x / (width + itemSpacing));
|
|
149
|
+
const isLoopHandled = manager?.handleMomentumScrollEnd(scrollIndex);
|
|
150
|
+
if (isLoopHandled) {
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
149
153
|
const {
|
|
150
154
|
realIndex,
|
|
151
155
|
needsJump,
|
|
@@ -335,7 +339,7 @@ export const useGestureViewer = ({
|
|
|
335
339
|
};
|
|
336
340
|
}, [animateBackdrop]);
|
|
337
341
|
const onScrollBeginDrag = useCallback(() => {
|
|
338
|
-
manager?.
|
|
342
|
+
manager?.handleScrollBeginDrag();
|
|
339
343
|
}, [manager]);
|
|
340
344
|
return {
|
|
341
345
|
currentIndex,
|
|
@@ -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","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","cancelAnimation"],"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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AAK,KAAK,CAAC,EAAE;MACzC,OAAO;QAAE2E,OAAO,EAAE;MAAE,CAAC;IACvB;IAEA,MAAMA,OAAO,GAAG9I,WAAW,CAAC8C,UAAU,CAACqB,KAAK,EAAE,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,OAAO,CAAC;IAExE,OAAO;MAAE2E;IAAQ,CAAC;EACpB,CAAC,EAAE,CAAC1H,eAAe,CAAC,CAAC;EAErB,MAAM2H,iBAAiB,GAAGxJ,WAAW,CAAC,MAAM;IAC1CiD,OAAO,EAAEwG,eAAe,CAAC,CAAC;EAC5B,CAAC,EAAE,CAACxG,OAAO,CAAC,CAAC;EAEb,OAAO;IACLF,YAAY;IACZc,UAAU;IACVN,UAAU;IACVK,OAAO;IACPjB,QAAQ;IACRE,SAAS;IACT+D,cAAc;IACdoC,WAAW;IAEXhD,mBAAmB;IACnBwD,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","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,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,SAASC,QAAQ,QAAQ,4BAAyB;AAElD,SAASC,sBAAsB,EAAEC,kBAAkB,EAAEC,oBAAoB,QAAQ,YAAS;AAO1F,OAAO,MAAMC,gBAAgB,GAAGA,CAAU;EACxCC,IAAI;EACJC,YAAY,GAAG,CAAC;EAChBC,aAAa;EACbC,SAAS;EACTC,KAAK,EAAEC,WAAW;EAClBC,gBAAgB,GAAG,EAAE;EACrBC,UAAU,GAAG,CAAC;EACd;EACA;EACAC,eAAe,GAAG,IAAI;EACtBC,oBAAo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AC;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":[]}
|
|
@@ -5,18 +5,17 @@ declare class GestureViewerManager {
|
|
|
5
5
|
private dataLength;
|
|
6
6
|
private width;
|
|
7
7
|
private height;
|
|
8
|
-
private scale;
|
|
9
|
-
private translateX;
|
|
10
|
-
private translateY;
|
|
11
8
|
private maxZoomScale;
|
|
12
|
-
private listRef;
|
|
13
9
|
private enableSwipeGesture;
|
|
14
10
|
private enableLoop;
|
|
15
|
-
private
|
|
11
|
+
private listRef;
|
|
12
|
+
private scale;
|
|
16
13
|
private rotation;
|
|
14
|
+
private translateX;
|
|
15
|
+
private translateY;
|
|
16
|
+
private loopCallback;
|
|
17
|
+
private listeners;
|
|
17
18
|
private eventListeners;
|
|
18
|
-
private animationTimeout;
|
|
19
|
-
private static readonly LOOP_ANIMATION_DURATION;
|
|
20
19
|
private notifyListeners;
|
|
21
20
|
subscribe(listener: (state: GestureViewerControllerState) => void): () => void;
|
|
22
21
|
addEventListener<T extends GestureViewerEventType>(eventType: T, callback: GestureViewerEventCallback<T>): () => void;
|
|
@@ -42,7 +41,8 @@ declare class GestureViewerManager {
|
|
|
42
41
|
zoomOut: (multiplier?: number) => void;
|
|
43
42
|
resetZoom: (scale?: number) => void;
|
|
44
43
|
goToIndex: (index: number) => void;
|
|
45
|
-
|
|
44
|
+
handleMomentumScrollEnd: (scrollIndex: number) => boolean;
|
|
45
|
+
handleScrollBeginDrag: () => void;
|
|
46
46
|
goToPrevious: () => void;
|
|
47
47
|
goToNext: () => void;
|
|
48
48
|
cleanUp(): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GestureViewerManager.d.ts","sourceRoot":"","sources":["../../../src/GestureViewerManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,WAAW,EAAc,MAAM,yBAAyB,CAAC;AACvE,OAAO,KAAK,EACV,4BAA4B,EAC5B,0BAA0B,EAE1B,sBAAsB,EACvB,MAAM,SAAS,CAAC;AAGjB,cAAM,oBAAoB;IACxB,OAAO,CAAC,YAAY,CAAK;IACzB,OAAO,CAAC,UAAU,CAAK;IACvB,OAAO,CAAC,KAAK,CAAK;IAClB,OAAO,CAAC,MAAM,CAAK;IACnB,OAAO,CAAC,
|
|
1
|
+
{"version":3,"file":"GestureViewerManager.d.ts","sourceRoot":"","sources":["../../../src/GestureViewerManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,WAAW,EAAc,MAAM,yBAAyB,CAAC;AACvE,OAAO,KAAK,EACV,4BAA4B,EAC5B,0BAA0B,EAE1B,sBAAsB,EACvB,MAAM,SAAS,CAAC;AAGjB,cAAM,oBAAoB;IACxB,OAAO,CAAC,YAAY,CAAK;IACzB,OAAO,CAAC,UAAU,CAAK;IACvB,OAAO,CAAC,KAAK,CAAK;IAClB,OAAO,CAAC,MAAM,CAAK;IACnB,OAAO,CAAC,YAAY,CAAK;IACzB,OAAO,CAAC,kBAAkB,CAAQ;IAClC,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,OAAO,CAAoB;IAEnC,OAAO,CAAC,KAAK,CAAoC;IACjD,OAAO,CAAC,QAAQ,CAAoC;IACpD,OAAO,CAAC,UAAU,CAAoC;IACtD,OAAO,CAAC,UAAU,CAAoC;IAEtD,OAAO,CAAC,YAAY,CAA6B;IAEjD,OAAO,CAAC,SAAS,CAA4D;IAC7E,OAAO,CAAC,cAAc,CAA+D;IAErF,OAAO,CAAC,eAAe;IAMvB,SAAS,CAAC,QAAQ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H;AAED,eAAe,oBAAoB,CAAC"}
|
|
@@ -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;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-gesture-image-viewer",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.2",
|
|
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://
|
|
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": {
|
|
@@ -12,19 +12,20 @@ class GestureViewerManager {
|
|
|
12
12
|
private dataLength = 0;
|
|
13
13
|
private width = 0;
|
|
14
14
|
private height = 0;
|
|
15
|
-
private scale: SharedValue<number> | null = null;
|
|
16
|
-
private translateX: SharedValue<number> | null = null;
|
|
17
|
-
private translateY: SharedValue<number> | null = null;
|
|
18
15
|
private maxZoomScale = 2;
|
|
19
|
-
private listRef: any | null = null;
|
|
20
16
|
private enableSwipeGesture = true;
|
|
21
17
|
private enableLoop = false;
|
|
22
|
-
private
|
|
18
|
+
private listRef: any | null = null;
|
|
19
|
+
|
|
20
|
+
private scale: SharedValue<number> | null = null;
|
|
23
21
|
private rotation: SharedValue<number> | null = null;
|
|
24
|
-
private
|
|
25
|
-
private
|
|
22
|
+
private translateX: SharedValue<number> | null = null;
|
|
23
|
+
private translateY: SharedValue<number> | null = null;
|
|
26
24
|
|
|
27
|
-
private
|
|
25
|
+
private loopCallback: (() => void) | null = null;
|
|
26
|
+
|
|
27
|
+
private listeners = new Set<(state: GestureViewerControllerState) => void>();
|
|
28
|
+
private eventListeners = new Map<GestureViewerEventType, Set<(data: any) => void>>();
|
|
28
29
|
|
|
29
30
|
private notifyListeners() {
|
|
30
31
|
const state = this.getState();
|
|
@@ -227,34 +228,34 @@ class GestureViewerManager {
|
|
|
227
228
|
return;
|
|
228
229
|
}
|
|
229
230
|
|
|
230
|
-
this.
|
|
231
|
+
this.loopCallback = null;
|
|
231
232
|
|
|
232
233
|
const { scrollTo } = createScrollAction(this.listRef, this.width);
|
|
233
234
|
|
|
234
235
|
if (this.enableLoop && this.dataLength > 1) {
|
|
235
236
|
if (index < 0) {
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
this.animationTimeout = setTimeout(() => {
|
|
237
|
+
this.loopCallback = () => {
|
|
239
238
|
scrollTo(this.dataLength, false);
|
|
240
239
|
this.updateCurrentIndex(this.dataLength - 1);
|
|
241
|
-
|
|
240
|
+
this.loopCallback = null;
|
|
241
|
+
};
|
|
242
|
+
|
|
243
|
+
scrollTo(0, true);
|
|
242
244
|
return;
|
|
243
245
|
}
|
|
244
246
|
|
|
245
247
|
if (index >= this.dataLength) {
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
this.animationTimeout = setTimeout(() => {
|
|
248
|
+
this.loopCallback = () => {
|
|
249
249
|
scrollTo(1, false);
|
|
250
250
|
this.updateCurrentIndex(0);
|
|
251
|
-
|
|
251
|
+
this.loopCallback = null;
|
|
252
|
+
};
|
|
253
|
+
|
|
254
|
+
scrollTo(this.dataLength + 1, true);
|
|
252
255
|
return;
|
|
253
256
|
}
|
|
254
257
|
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
scrollTo(scrollIndex, true);
|
|
258
|
+
scrollTo(index + 1, true);
|
|
258
259
|
this.updateCurrentIndex(index);
|
|
259
260
|
|
|
260
261
|
return;
|
|
@@ -268,11 +269,22 @@ class GestureViewerManager {
|
|
|
268
269
|
this.updateCurrentIndex(index);
|
|
269
270
|
};
|
|
270
271
|
|
|
271
|
-
|
|
272
|
-
if (this.
|
|
273
|
-
|
|
274
|
-
|
|
272
|
+
handleMomentumScrollEnd = (scrollIndex: number) => {
|
|
273
|
+
if (!this.loopCallback) {
|
|
274
|
+
return false;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
if (scrollIndex === 0 || scrollIndex === this.dataLength + 1) {
|
|
278
|
+
this.loopCallback();
|
|
279
|
+
return true;
|
|
275
280
|
}
|
|
281
|
+
|
|
282
|
+
this.loopCallback = null;
|
|
283
|
+
return true;
|
|
284
|
+
};
|
|
285
|
+
|
|
286
|
+
handleScrollBeginDrag = () => {
|
|
287
|
+
this.loopCallback = null;
|
|
276
288
|
};
|
|
277
289
|
|
|
278
290
|
goToPrevious = () => {
|
|
@@ -284,7 +296,7 @@ class GestureViewerManager {
|
|
|
284
296
|
};
|
|
285
297
|
|
|
286
298
|
cleanUp() {
|
|
287
|
-
this.
|
|
299
|
+
this.loopCallback = null;
|
|
288
300
|
this.listeners.clear();
|
|
289
301
|
this.listRef = null;
|
|
290
302
|
this.enableSwipeGesture = true;
|
package/src/useGestureViewer.ts
CHANGED
|
@@ -228,6 +228,12 @@ export const useGestureViewer = <T = any>({
|
|
|
228
228
|
const contentOffset = event.nativeEvent.contentOffset;
|
|
229
229
|
const scrollIndex = Math.round(contentOffset.x / (width + itemSpacing));
|
|
230
230
|
|
|
231
|
+
const isLoopHandled = manager?.handleMomentumScrollEnd(scrollIndex);
|
|
232
|
+
|
|
233
|
+
if (isLoopHandled) {
|
|
234
|
+
return;
|
|
235
|
+
}
|
|
236
|
+
|
|
231
237
|
const { realIndex, needsJump, jumpToIndex } = getLoopAdjustedIndex(scrollIndex, dataLength, enableLoop);
|
|
232
238
|
|
|
233
239
|
if (needsJump && jumpToIndex !== undefined) {
|
|
@@ -482,7 +488,7 @@ export const useGestureViewer = <T = any>({
|
|
|
482
488
|
}, [animateBackdrop]);
|
|
483
489
|
|
|
484
490
|
const onScrollBeginDrag = useCallback(() => {
|
|
485
|
-
manager?.
|
|
491
|
+
manager?.handleScrollBeginDrag();
|
|
486
492
|
}, [manager]);
|
|
487
493
|
|
|
488
494
|
return {
|