react-native-gesture-image-viewer 2.4.0 → 3.0.0-beta.1

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.
Files changed (138) hide show
  1. package/README.md +5 -3
  2. package/lib/module/GestureViewer.js +96 -147
  3. package/lib/module/GestureViewer.js.map +1 -1
  4. package/lib/module/GestureViewerManager.js +49 -105
  5. package/lib/module/GestureViewerManager.js.map +1 -1
  6. package/lib/module/gestureViewerAnimation.js +18 -0
  7. package/lib/module/gestureViewerAnimation.js.map +1 -0
  8. package/lib/module/gestureViewerGestures.js +12 -0
  9. package/lib/module/gestureViewerGestures.js.map +1 -0
  10. package/lib/module/gestureViewerPaging.js +66 -0
  11. package/lib/module/gestureViewerPaging.js.map +1 -0
  12. package/lib/module/gestureViewerRenderWindow.js +29 -0
  13. package/lib/module/gestureViewerRenderWindow.js.map +1 -0
  14. package/lib/module/getWebContentProps.js +6 -0
  15. package/lib/module/getWebContentProps.js.map +1 -0
  16. package/lib/module/getWebContentProps.web.js +8 -0
  17. package/lib/module/getWebContentProps.web.js.map +1 -0
  18. package/lib/module/platformTapGestures.js +4 -0
  19. package/lib/module/platformTapGestures.js.map +1 -0
  20. package/lib/module/platformTapGestures.web.js +4 -0
  21. package/lib/module/platformTapGestures.web.js.map +1 -0
  22. package/lib/module/renderWindow.js +160 -0
  23. package/lib/module/renderWindow.js.map +1 -0
  24. package/lib/module/useGestureViewer.js +459 -211
  25. package/lib/module/useGestureViewer.js.map +1 -1
  26. package/lib/module/useGestureViewerController.js +3 -3
  27. package/lib/module/useGestureViewerController.js.map +1 -1
  28. package/lib/module/useGestureViewerManagerBridge.js +85 -0
  29. package/lib/module/useGestureViewerManagerBridge.js.map +1 -0
  30. package/lib/module/useGestureViewerPaging.js +168 -79
  31. package/lib/module/useGestureViewerPaging.js.map +1 -1
  32. package/lib/module/useWebClickHandler.js +7 -0
  33. package/lib/module/useWebClickHandler.js.map +1 -0
  34. package/lib/module/useWebClickHandler.web.js +85 -0
  35. package/lib/module/useWebClickHandler.web.js.map +1 -0
  36. package/lib/module/useWebSingleTapTimer.js +12 -0
  37. package/lib/module/useWebSingleTapTimer.js.map +1 -0
  38. package/lib/module/useWebSingleTapTimer.web.js +25 -0
  39. package/lib/module/useWebSingleTapTimer.web.js.map +1 -0
  40. package/lib/module/utils/index.js +0 -77
  41. package/lib/module/utils/index.js.map +1 -1
  42. package/lib/module/utils/tapZoom.js +4 -3
  43. package/lib/module/utils/tapZoom.js.map +1 -1
  44. package/lib/typescript/src/GestureViewer.d.ts +1 -1
  45. package/lib/typescript/src/GestureViewer.d.ts.map +1 -1
  46. package/lib/typescript/src/GestureViewerManager.d.ts +20 -20
  47. package/lib/typescript/src/GestureViewerManager.d.ts.map +1 -1
  48. package/lib/typescript/src/gestureViewerAnimation.d.ts +15 -0
  49. package/lib/typescript/src/gestureViewerAnimation.d.ts.map +1 -0
  50. package/lib/typescript/src/gestureViewerGestures.d.ts +10 -0
  51. package/lib/typescript/src/gestureViewerGestures.d.ts.map +1 -0
  52. package/lib/typescript/src/gestureViewerPaging.d.ts +13 -0
  53. package/lib/typescript/src/gestureViewerPaging.d.ts.map +1 -0
  54. package/lib/typescript/src/gestureViewerRenderWindow.d.ts +15 -0
  55. package/lib/typescript/src/gestureViewerRenderWindow.d.ts.map +1 -0
  56. package/lib/typescript/src/getWebContentProps.d.ts +3 -0
  57. package/lib/typescript/src/getWebContentProps.d.ts.map +1 -0
  58. package/lib/typescript/src/getWebContentProps.web.d.ts +5 -0
  59. package/lib/typescript/src/getWebContentProps.web.d.ts.map +1 -0
  60. package/lib/typescript/src/platformTapGestures.d.ts +2 -0
  61. package/lib/typescript/src/platformTapGestures.d.ts.map +1 -0
  62. package/lib/typescript/src/platformTapGestures.web.d.ts +2 -0
  63. package/lib/typescript/src/platformTapGestures.web.d.ts.map +1 -0
  64. package/lib/typescript/src/renderWindow.d.ts +44 -0
  65. package/lib/typescript/src/renderWindow.d.ts.map +1 -0
  66. package/lib/typescript/src/types.d.ts +36 -53
  67. package/lib/typescript/src/types.d.ts.map +1 -1
  68. package/lib/typescript/src/useGestureViewer.d.ts +11 -10
  69. package/lib/typescript/src/useGestureViewer.d.ts.map +1 -1
  70. package/lib/typescript/src/useGestureViewerController.d.ts +1 -1
  71. package/lib/typescript/src/useGestureViewerManagerBridge.d.ts +28 -0
  72. package/lib/typescript/src/useGestureViewerManagerBridge.d.ts.map +1 -0
  73. package/lib/typescript/src/useGestureViewerPaging.d.ts +33 -2
  74. package/lib/typescript/src/useGestureViewerPaging.d.ts.map +1 -1
  75. package/lib/typescript/src/useWebClickHandler.d.ts +35 -0
  76. package/lib/typescript/src/useWebClickHandler.d.ts.map +1 -0
  77. package/lib/typescript/src/useWebClickHandler.web.d.ts +36 -0
  78. package/lib/typescript/src/useWebClickHandler.web.d.ts.map +1 -0
  79. package/lib/typescript/src/useWebSingleTapTimer.d.ts +6 -0
  80. package/lib/typescript/src/useWebSingleTapTimer.d.ts.map +1 -0
  81. package/lib/typescript/src/useWebSingleTapTimer.web.d.ts +6 -0
  82. package/lib/typescript/src/useWebSingleTapTimer.web.d.ts.map +1 -0
  83. package/lib/typescript/src/utils/index.d.ts +0 -20
  84. package/lib/typescript/src/utils/index.d.ts.map +1 -1
  85. package/lib/typescript/src/utils/tapZoom.d.ts.map +1 -1
  86. package/package.json +2 -2
  87. package/src/GestureViewer.tsx +113 -208
  88. package/src/GestureViewerManager.ts +77 -122
  89. package/src/gestureViewerAnimation.ts +18 -0
  90. package/src/gestureViewerGestures.ts +20 -0
  91. package/src/gestureViewerPaging.ts +116 -0
  92. package/src/gestureViewerRenderWindow.ts +56 -0
  93. package/src/getWebContentProps.ts +5 -0
  94. package/src/getWebContentProps.web.ts +5 -0
  95. package/src/platformTapGestures.ts +1 -0
  96. package/src/platformTapGestures.web.ts +1 -0
  97. package/src/renderWindow.ts +253 -0
  98. package/src/types.ts +34 -100
  99. package/src/useGestureViewer.ts +665 -275
  100. package/src/useGestureViewerController.ts +3 -3
  101. package/src/useGestureViewerManagerBridge.ts +118 -0
  102. package/src/useGestureViewerPaging.ts +306 -112
  103. package/src/useWebClickHandler.ts +44 -0
  104. package/src/useWebClickHandler.web.ts +146 -0
  105. package/src/useWebSingleTapTimer.ts +10 -0
  106. package/src/useWebSingleTapTimer.web.ts +30 -0
  107. package/src/utils/index.ts +0 -102
  108. package/src/utils/tapZoom.ts +4 -3
  109. package/lib/module/WebPagingFixStyle.js +0 -25
  110. package/lib/module/WebPagingFixStyle.js.map +0 -1
  111. package/lib/module/scheduleInitialScroll.js +0 -21
  112. package/lib/module/scheduleInitialScroll.js.map +0 -1
  113. package/lib/module/useGestureViewerPaging.types.js +0 -4
  114. package/lib/module/useGestureViewerPaging.types.js.map +0 -1
  115. package/lib/module/useGestureViewerPaging.web.js +0 -291
  116. package/lib/module/useGestureViewerPaging.web.js.map +0 -1
  117. package/lib/module/utils/FlashList.js +0 -9
  118. package/lib/module/utils/FlashList.js.map +0 -1
  119. package/lib/module/utils/webScroll.js +0 -70
  120. package/lib/module/utils/webScroll.js.map +0 -1
  121. package/lib/typescript/src/WebPagingFixStyle.d.ts +0 -6
  122. package/lib/typescript/src/WebPagingFixStyle.d.ts.map +0 -1
  123. package/lib/typescript/src/scheduleInitialScroll.d.ts +0 -3
  124. package/lib/typescript/src/scheduleInitialScroll.d.ts.map +0 -1
  125. package/lib/typescript/src/useGestureViewerPaging.types.d.ts +0 -42
  126. package/lib/typescript/src/useGestureViewerPaging.types.d.ts.map +0 -1
  127. package/lib/typescript/src/useGestureViewerPaging.web.d.ts +0 -3
  128. package/lib/typescript/src/useGestureViewerPaging.web.d.ts.map +0 -1
  129. package/lib/typescript/src/utils/FlashList.d.ts +0 -2
  130. package/lib/typescript/src/utils/FlashList.d.ts.map +0 -1
  131. package/lib/typescript/src/utils/webScroll.d.ts +0 -18
  132. package/lib/typescript/src/utils/webScroll.d.ts.map +0 -1
  133. package/src/WebPagingFixStyle.tsx +0 -25
  134. package/src/scheduleInitialScroll.ts +0 -36
  135. package/src/useGestureViewerPaging.types.ts +0 -42
  136. package/src/useGestureViewerPaging.web.ts +0 -453
  137. package/src/utils/FlashList.ts +0 -7
  138. package/src/utils/webScroll.ts +0 -96
package/README.md CHANGED
@@ -23,7 +23,7 @@ Existing libraries often have limited customization options or performance issue
23
23
  - 🎨 **Full Customization** - Total control over components, styles, and gesture behavior
24
24
  - 🎛️ **External Control API** - Trigger actions programmatically from buttons or other UI components
25
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
26
+ - 🧬 **Flexible Integration** - Use with Modal, [React Native Modal](https://www.npmjs.com/package/react-native-modal), [Expo Image](https://www.npmjs.com/package/expo-image), [FastImage](https://github.com/DylanVann/react-native-fast-image), videos, and custom content
27
27
  - 🧠 **Full TypeScript Support** - Great developer experience with type inference and safety
28
28
  - 🌐 **Cross-Platform** - Runs on iOS, Android, and Web with Expo Go and New Architecture compatibility
29
29
  - 🪄 **Easy-to-Use API** - Simple and intuitive API that requires minimal setup
@@ -34,6 +34,8 @@ Existing libraries often have limited customization options or performance issue
34
34
 
35
35
  Full documentation is available at: <https://react-native-gesture-image-viewer.pages.dev>
36
36
 
37
+ > v3 is currently in beta. Install it with `react-native-gesture-image-viewer@beta` and use the [v3 beta docs](https://react-native-gesture-image-viewer.pages.dev/3.x-beta/). The docs root still points to the stable v2 documentation.
38
+
37
39
  ### Examples & Demo
38
40
 
39
41
  - [📁 Example Project](/example/) - Real implementation code with various use cases
@@ -50,7 +52,7 @@ Full documentation is available at: <https://react-native-gesture-image-viewer.p
50
52
 
51
53
  ```tsx
52
54
  import { useCallback, useState } from 'react';
53
- import { ScrollView, Image, Modal, View, Text, Button, Pressable } from 'react-native';
55
+ import { Image, Modal, View, Text, Button, Pressable } from 'react-native';
54
56
  import {
55
57
  GestureViewer,
56
58
  GestureTrigger,
@@ -95,7 +97,7 @@ function App() {
95
97
  data={images}
96
98
  initialIndex={selectedIndex}
97
99
  renderItem={renderImage}
98
- ListComponent={ScrollView}
100
+ pageSpacing={16}
99
101
  onDismiss={() => setVisible(false)}
100
102
  />
101
103
  <View>
@@ -1,212 +1,161 @@
1
1
  "use strict";
2
2
 
3
- import { useCallback, useEffect, useMemo, useRef } from 'react';
4
- import { Platform, StyleSheet, useWindowDimensions, View } from 'react-native';
5
- import { Gesture, GestureDetector, GestureHandlerRootView } from 'react-native-gesture-handler';
6
- import Animated from 'react-native-reanimated';
3
+ import { useEffect, useMemo } from 'react';
4
+ import { StyleSheet, useWindowDimensions, View } from 'react-native';
5
+ import { GestureDetector, GestureHandlerRootView } from 'react-native-gesture-handler';
6
+ import Animated, { useAnimatedStyle } from 'react-native-reanimated';
7
+ import { composeGestureViewerGestures } from "./gestureViewerGestures.js";
7
8
  import { registry } from "./GestureViewerRegistry.js";
9
+ import { getWebContentProps } from './getWebContentProps';
8
10
  import { useGestureViewer } from "./useGestureViewer.js";
9
- import { createLoopData, isFlashListLike, isFlatListLike, isScrollViewLike, shouldUseNativeScrollGesture } from "./utils/index.js";
10
- import WebPagingFixStyle from "./WebPagingFixStyle.js";
11
11
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
12
+ function RenderWindowSlotView({
13
+ animatedStyle,
14
+ height,
15
+ isActive,
16
+ pageStride,
17
+ renderItem,
18
+ slot,
19
+ visualPage,
20
+ width
21
+ }) {
22
+ const slotAnimatedStyle = useAnimatedStyle(() => ({
23
+ transform: [{
24
+ translateX: (slot.virtualIndex - visualPage.get()) * pageStride
25
+ }]
26
+ }));
27
+ return /*#__PURE__*/_jsx(Animated.View, {
28
+ style: [styles.slot, {
29
+ height,
30
+ width
31
+ }, slotAnimatedStyle],
32
+ children: /*#__PURE__*/_jsx(Animated.View, {
33
+ style: [styles.page, isActive && animatedStyle],
34
+ children: /*#__PURE__*/_jsx(View, {
35
+ style: [styles.item, {
36
+ height,
37
+ width
38
+ }],
39
+ children: renderItem(slot.item, slot.logicalIndex, {
40
+ isActive
41
+ })
42
+ })
43
+ })
44
+ });
45
+ }
12
46
  export function GestureViewer({
13
47
  id = 'default',
14
48
  data,
15
- renderItem: renderItemProp,
49
+ renderItem,
16
50
  renderContainer,
17
- ListComponent,
18
51
  width: customWidth,
19
52
  height: customHeight,
20
- listProps,
21
53
  backdropStyle: backdropStyleProps,
22
54
  containerStyle,
23
55
  initialIndex = 0,
24
- itemSpacing = 0,
25
- enableSnapMode = false,
56
+ pageSpacing = 0,
57
+ windowSize = 3,
26
58
  enableLoop = false,
27
59
  ...props
28
60
  }) {
29
- const Component = ListComponent;
30
- const dataRef = useRef(data);
31
61
  const {
32
62
  width: screenWidth,
33
63
  height: screenHeight
34
64
  } = useWindowDimensions();
35
65
  const width = customWidth || screenWidth;
36
66
  const height = customHeight || screenHeight;
37
- const loopData = useMemo(() => createLoopData(dataRef, enableLoop), [enableLoop]);
38
- const isScrollView = isScrollViewLike(Component);
39
- const isFlashList = isFlashListLike(Component);
40
67
  const {
41
- activeListIndex,
42
- listRef,
43
- isZoomed,
44
- isRotated,
45
- isPinching,
46
- dismissGesture,
47
- zoomGesture,
48
- nativeScrollGesture,
49
- onWebClick,
50
- onMomentumScrollEnd,
51
- onScroll,
52
- onScrollBeginDrag,
53
68
  animatedStyle,
54
69
  backdropStyle,
55
- handleDismiss
70
+ centerVirtualIndex,
71
+ dismissGesture,
72
+ handleDismiss,
73
+ horizontalPagingGesture,
74
+ onWebClick,
75
+ pageStride,
76
+ renderWindowSlots,
77
+ visualPage,
78
+ zoomGesture,
79
+ zoomPinchGesture
56
80
  } = useGestureViewer({
57
81
  id,
58
82
  data,
59
83
  width,
60
84
  height,
61
85
  initialIndex,
62
- itemSpacing,
86
+ pageSpacing,
87
+ windowSize,
63
88
  enableLoop,
64
89
  ...props
65
90
  });
66
- const keyExtractor = useCallback((item, index) => {
67
- if (enableLoop) {
68
- return typeof item === 'string' ? `${item}-${index}` : `item-${index}`;
69
- }
70
- return typeof item === 'string' ? item : `image-${index}`;
71
- }, [enableLoop]);
72
- const renderItem = useCallback(({
73
- item,
74
- index,
75
- target
76
- }) => {
77
- const isFlashListCell = !isFlashList || target === undefined || target === 'Cell';
78
- return /*#__PURE__*/_jsx(View, {
79
- style: [{
80
- width,
81
- height,
82
- marginHorizontal: itemSpacing / 2
83
- }, styles.item],
84
- children: renderItemProp(item, index, {
85
- isActive: index === activeListIndex && isFlashListCell
86
- })
87
- }, isScrollView ? keyExtractor(item, index) : undefined);
88
- }, [activeListIndex, width, itemSpacing, renderItemProp, keyExtractor, isScrollView, isFlashList, height]);
89
- const getItemLayout = useCallback((_, index) => ({
90
- length: width + itemSpacing,
91
- offset: (width + itemSpacing) * index,
92
- index
93
- }), [width, itemSpacing]);
94
91
  const gesture = useMemo(() => {
95
- return Gesture.Race(dismissGesture, zoomGesture);
96
- }, [zoomGesture, dismissGesture]);
97
- useEffect(() => {
98
- dataRef.current = data;
99
- }, [data]);
92
+ return composeGestureViewerGestures({
93
+ dismissGesture,
94
+ horizontalPagingGesture,
95
+ zoomGesture,
96
+ zoomPinchGesture
97
+ });
98
+ }, [dismissGesture, horizontalPagingGesture, zoomGesture, zoomPinchGesture]);
100
99
  useEffect(() => {
101
100
  registry.createManager(id);
102
101
  return () => registry.deleteManager(id);
103
102
  }, [id]);
104
- const commonProps = useMemo(() => ({
105
- horizontal: true,
106
- scrollEnabled: !isZoomed && !isRotated && !isPinching,
107
- showsHorizontalScrollIndicator: false,
108
- onMomentumScrollEnd,
109
- onScroll,
110
- onScrollBeginDrag,
111
- ...(enableSnapMode ? {
112
- snapToInterval: width + itemSpacing,
113
- snapToAlignment: 'center',
114
- decelerationRate: 'fast'
115
- } : {
116
- pagingEnabled: true
117
- }),
118
- scrollEventThrottle: 16,
119
- removeClippedSubviews: true
120
- }), [width, itemSpacing, isZoomed, isRotated, isPinching, onMomentumScrollEnd, onScroll, onScrollBeginDrag, enableSnapMode]);
121
103
  const control = useMemo(() => ({
122
104
  dismiss: handleDismiss
123
105
  }), [handleDismiss]);
124
- const shouldWrapScrollableWithNativeGesture = shouldUseNativeScrollGesture(Platform.OS, Component);
125
- const maybeWrapWithNativeScrollGesture = useCallback(children => {
126
- if (!shouldWrapScrollableWithNativeGesture) {
127
- return children;
128
- }
129
- return /*#__PURE__*/_jsx(GestureDetector, {
130
- gesture: nativeScrollGesture,
131
- children: children
132
- });
133
- }, [nativeScrollGesture, shouldWrapScrollableWithNativeGesture]);
134
- const listComponent = /*#__PURE__*/_jsx(GestureHandlerRootView, {
106
+ const webContentProps = getWebContentProps(onWebClick);
107
+ const viewer = /*#__PURE__*/_jsx(GestureHandlerRootView, {
135
108
  children: /*#__PURE__*/_jsx(GestureDetector, {
136
109
  gesture: gesture,
137
110
  children: /*#__PURE__*/_jsxs(View, {
138
- style: [{
139
- width,
140
- height
111
+ style: [styles.container, {
112
+ height,
113
+ width
141
114
  }, containerStyle],
142
115
  children: [/*#__PURE__*/_jsx(Animated.View, {
143
116
  style: [styles.background, backdropStyleProps, backdropStyle]
144
117
  }), /*#__PURE__*/_jsx(Animated.View, {
145
- style: [styles.content, animatedStyle],
146
- ...(Platform.OS === 'web' && {
147
- onClick: onWebClick
148
- }),
149
- ...(Platform.OS === 'web' && isFlashList && {
150
- dataSet: {
151
- 'flash-list-paging-enabled-fix': true
152
- }
153
- }),
154
- children: isScrollView ? maybeWrapWithNativeScrollGesture(/*#__PURE__*/_jsx(Component, {
155
- ref: listRef,
156
- ...commonProps,
157
- ...listProps,
158
- children: loopData.map((item, index) => renderItem({
159
- item,
160
- index
161
- }))
162
- })) : isFlatListLike(Component) && maybeWrapWithNativeScrollGesture(/*#__PURE__*/_jsx(Component, {
163
- ref: listRef,
164
- ...commonProps,
165
- data: loopData,
118
+ style: styles.content,
119
+ ...webContentProps,
120
+ children: renderWindowSlots.map(slot => /*#__PURE__*/_jsx(RenderWindowSlotView, {
121
+ animatedStyle: animatedStyle,
122
+ height: height,
123
+ isActive: slot.virtualIndex === centerVirtualIndex,
124
+ pageStride: pageStride,
166
125
  renderItem: renderItem,
167
- initialScrollIndex: enableLoop && data.length > 1 ? initialIndex + 1 : initialIndex,
168
- keyExtractor: keyExtractor,
169
- ...(isFlashList ?
170
- // NOTE - Deprecated estimatedItemSize for FlashList V2 (https://shopify.github.io/flash-list/docs/v2-changes#deprecated)
171
- {
172
- estimatedItemSize: width + itemSpacing
173
- } : {
174
- windowSize: 3,
175
- maxToRenderPerBatch: 3,
176
- getItemLayout
177
- }),
178
- ...(Platform.OS === 'web' && isFlatListLike(Component) && {
179
- dataSet: {
180
- 'flat-list-paging-enabled-fix': true
181
- }
182
- }),
183
- ...listProps
184
- }))
185
- }), /*#__PURE__*/_jsx(WebPagingFixStyle, {
186
- Component: Component
126
+ slot: slot,
127
+ visualPage: visualPage,
128
+ width: width
129
+ }, slot.slotKey))
187
130
  })]
188
131
  })
189
132
  })
190
133
  });
191
- return renderContainer ? renderContainer(listComponent, control) : listComponent;
134
+ return renderContainer ? renderContainer(viewer, control) : viewer;
192
135
  }
193
136
  const styles = StyleSheet.create({
137
+ background: {
138
+ ...StyleSheet.absoluteFill,
139
+ backgroundColor: '#000'
140
+ },
141
+ container: {
142
+ overflow: 'hidden'
143
+ },
194
144
  content: {
195
- flex: 1,
196
- width: '100%',
197
- height: '100%'
145
+ ...StyleSheet.absoluteFill,
146
+ overflow: 'hidden'
198
147
  },
199
148
  item: {
200
- justifyContent: 'center',
201
- alignItems: 'center'
149
+ alignItems: 'center',
150
+ justifyContent: 'center'
202
151
  },
203
- background: {
204
- position: 'absolute',
205
- top: 0,
152
+ page: {
153
+ flex: 1
154
+ },
155
+ slot: {
206
156
  left: 0,
207
- right: 0,
208
- bottom: 0,
209
- backgroundColor: 'black'
157
+ position: 'absolute',
158
+ top: 0
210
159
  }
211
160
  });
212
161
  //# sourceMappingURL=GestureViewer.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["useCallback","useEffect","useMemo","useRef","Platform","StyleSheet","useWindowDimensions","View","Gesture","GestureDetector","GestureHandlerRootView","Animated","registry","useGestureViewer","createLoopData","isFlashListLike","isFlatListLike","isScrollViewLike","shouldUseNativeScrollGesture","WebPagingFixStyle","jsx","_jsx","jsxs","_jsxs","GestureViewer","id","data","renderItem","renderItemProp","renderContainer","ListComponent","width","customWidth","height","customHeight","listProps","backdropStyle","backdropStyleProps","containerStyle","initialIndex","itemSpacing","enableSnapMode","enableLoop","props","Component","dataRef","screenWidth","screenHeight","loopData","isScrollView","isFlashList","activeListIndex","listRef","isZoomed","isRotated","isPinching","dismissGesture","zoomGesture","nativeScrollGesture","onWebClick","onMomentumScrollEnd","onScroll","onScrollBeginDrag","animatedStyle","handleDismiss","keyExtractor","item","index","target","isFlashListCell","undefined","style","marginHorizontal","styles","children","isActive","getItemLayout","_","length","offset","gesture","Race","current","createManager","deleteManager","commonProps","horizontal","scrollEnabled","showsHorizontalScrollIndicator","snapToInterval","snapToAlignment","decelerationRate","pagingEnabled","scrollEventThrottle","removeClippedSubviews","control","dismiss","shouldWrapScrollableWithNativeGesture","OS","maybeWrapWithNativeScrollGesture","listComponent","background","content","onClick","dataSet","ref","map","initialScrollIndex","estimatedItemSize","windowSize","maxToRenderPerBatch","create","flex","justifyContent","alignItems","position","top","left","right","bottom","backgroundColor"],"sourceRoot":"../../src","sources":["GestureViewer.tsx"],"mappings":";;AAAA,SAASA,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,MAAM,QAAQ,OAAO;AAC/D,SACEC,QAAQ,EAERC,UAAU,EACVC,mBAAmB,EACnBC,IAAI,QACC,cAAc;AACrB,SAASC,OAAO,EAAEC,eAAe,EAAEC,sBAAsB,QAAQ,8BAA8B;AAC/F,OAAOC,QAAQ,MAAM,yBAAyB;AAE9C,SAASC,QAAQ,QAAQ,4BAAyB;AAElD,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AC0G,MAAM,CAAC;EAC/BT,OAAO,EAAE;IACPU,IAAI,EAAE,CAAC;IACPjF,KAAK,EAAE,MAAM;IACbE,MAAM,EAAE;EACV,CAAC;EACDiC,IAAI,EAAE;IACJ+C,cAAc,EAAE,QAAQ;IACxBC,UAAU,EAAE;EACd,CAAC;EACDb,UAAU,EAAE;IACVc,QAAQ,EAAE,UAAU;IACpBC,GAAG,EAAE,CAAC;IACNC,IAAI,EAAE,CAAC;IACPC,KAAK,EAAE,CAAC;IACRC,MAAM,EAAE,CAAC;IACTC,eAAe,EAAE;EACnB;AACF,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["useEffect","useMemo","StyleSheet","useWindowDimensions","View","GestureDetector","GestureHandlerRootView","Animated","useAnimatedStyle","composeGestureViewerGestures","registry","getWebContentProps","useGestureViewer","jsx","_jsx","jsxs","_jsxs","RenderWindowSlotView","animatedStyle","height","isActive","pageStride","renderItem","slot","visualPage","width","slotAnimatedStyle","transform","translateX","virtualIndex","get","style","styles","children","page","item","logicalIndex","GestureViewer","id","data","renderContainer","customWidth","customHeight","backdropStyle","backdropStyleProps","containerStyle","initialIndex","pageSpacing","windowSize","enableLoop","props","screenWidth","screenHeight","centerVirtualIndex","dismissGesture","handleDismiss","horizontalPagingGesture","onWebClick","renderWindowSlots","zoomGesture","zoomPinchGesture","gesture","createManager","deleteManager","control","dismiss","webContentProps","viewer","container","background","content","map","slotKey","create","absoluteFill","backgroundColor","overflow","alignItems","justifyContent","flex","left","position","top"],"sourceRoot":"../../src","sources":["GestureViewer.tsx"],"mappings":";;AAAA,SAASA,SAAS,EAAEC,OAAO,QAAQ,OAAO;AAC1C,SAASC,UAAU,EAAEC,mBAAmB,EAAEC,IAAI,QAAwB,cAAc;AACpF,SAASC,eAAe,EAAEC,sBAAsB,QAAQ,8BAA8B;AACtF,OAAOC,QAAQ,IAGbC,gBAAgB,QACX,yBAAyB;AAEhC,SAASC,4BAA4B,QAAQ,4BAAyB;AACtE,SAASC,QA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AC;EACDN,OAAO,EAAE;IACP,GAAGpE,UAAU,CAACwE,YAAY;IAC1BE,QAAQ,EAAE;EACZ,CAAC;EACDzC,IAAI,EAAE;IACJ0C,UAAU,EAAE,QAAQ;IACpBC,cAAc,EAAE;EAClB,CAAC;EACD5C,IAAI,EAAE;IACJ6C,IAAI,EAAE;EACR,CAAC;EACDxD,IAAI,EAAE;IACJyD,IAAI,EAAE,CAAC;IACPC,QAAQ,EAAE,UAAU;IACpBC,GAAG,EAAE;EACP;AACF,CAAC,CAAC","ignoreList":[]}
@@ -1,25 +1,24 @@
1
1
  "use strict";
2
2
 
3
3
  import { withTiming } from 'react-native-reanimated';
4
- import { createBoundsConstraint, createScrollAction } from "./utils/index.js";
4
+ import { createBoundsConstraint } from "./utils/index.js";
5
+ const DEFAULT_STATE_READER = () => ({
6
+ currentIndex: 0,
7
+ totalCount: 0
8
+ });
5
9
  class GestureViewerManager {
6
- currentIndex = 0;
7
- dataLength = 0;
8
10
  width = 0;
9
11
  height = 0;
10
12
  maxZoomScale = 2;
11
- enableHorizontalSwipe = true;
12
- enableLoop = false;
13
- listRef = null;
13
+ navigationAdapter = null;
14
+ stateReader = DEFAULT_STATE_READER;
14
15
  scale = null;
15
16
  rotation = null;
16
17
  translateX = null;
17
18
  translateY = null;
18
- resetTransformCallback = null;
19
- loopCallback = null;
20
- programmaticScrollVersion = 0;
21
19
  listeners = new Set();
22
20
  eventListeners = new Map();
21
+ eventListenerPresenceSubscribers = new Set();
23
22
  notifyListeners() {
24
23
  const state = this.getState();
25
24
  this.listeners.forEach(listener => listener(state));
@@ -35,6 +34,7 @@ class GestureViewerManager {
35
34
  this.eventListeners.set(eventType, new Set());
36
35
  }
37
36
  this.eventListeners.get(eventType)?.add(callback);
37
+ this.notifyEventListenerPresence(eventType);
38
38
  return () => {
39
39
  const listeners = this.eventListeners.get(eventType);
40
40
  if (listeners) {
@@ -43,8 +43,29 @@ class GestureViewerManager {
43
43
  this.eventListeners.delete(eventType);
44
44
  }
45
45
  }
46
+ this.notifyEventListenerPresence(eventType);
46
47
  };
47
48
  }
49
+ subscribeToEventListenerPresence(callback) {
50
+ this.eventListenerPresenceSubscribers.add(callback);
51
+ this.notifyEventListenerPresenceSubscriber(callback, 'zoomChange');
52
+ this.notifyEventListenerPresenceSubscriber(callback, 'rotationChange');
53
+ this.notifyEventListenerPresenceSubscriber(callback, 'tap');
54
+ return () => {
55
+ this.eventListenerPresenceSubscribers.delete(callback);
56
+ };
57
+ }
58
+ hasEventListeners(eventType) {
59
+ return (this.eventListeners.get(eventType)?.size ?? 0) > 0;
60
+ }
61
+ notifyEventListenerPresence(eventType) {
62
+ this.eventListenerPresenceSubscribers.forEach(callback => {
63
+ this.notifyEventListenerPresenceSubscriber(callback, eventType);
64
+ });
65
+ }
66
+ notifyEventListenerPresenceSubscriber(callback, eventType) {
67
+ callback(eventType, this.hasEventListeners(eventType));
68
+ }
48
69
  emitEvent(eventType, data) {
49
70
  const listeners = this.eventListeners.get(eventType);
50
71
  if (listeners) {
@@ -67,16 +88,7 @@ class GestureViewerManager {
67
88
  this.emitEvent('tap', data);
68
89
  };
69
90
  getState() {
70
- return {
71
- currentIndex: this.currentIndex,
72
- totalCount: this.dataLength
73
- };
74
- }
75
- getProgrammaticScrollVersion() {
76
- return this.programmaticScrollVersion;
77
- }
78
- setEnableLoop(enabled) {
79
- this.enableLoop = enabled;
91
+ return this.stateReader();
80
92
  }
81
93
  setWidth(width) {
82
94
  this.width = width;
@@ -84,19 +96,11 @@ class GestureViewerManager {
84
96
  setHeight(height) {
85
97
  this.height = height;
86
98
  }
87
- setListRef(ref) {
88
- this.listRef = ref;
89
- }
90
- setDataLength(length) {
91
- this.dataLength = length;
92
- }
93
- setEnableHorizontalSwipe(enabled) {
94
- this.enableHorizontalSwipe = enabled;
99
+ setNavigationAdapter(adapter) {
100
+ this.navigationAdapter = adapter;
95
101
  }
96
- setCurrentIndex(index) {
97
- if (index !== this.currentIndex) {
98
- this.currentIndex = index;
99
- }
102
+ setStateReader(reader) {
103
+ this.stateReader = reader ?? DEFAULT_STATE_READER;
100
104
  }
101
105
  setZoomSharedValues(scale, translateX, translateY, maxZoomScale) {
102
106
  this.scale = scale;
@@ -104,9 +108,6 @@ class GestureViewerManager {
104
108
  this.translateY = translateY;
105
109
  this.maxZoomScale = maxZoomScale;
106
110
  }
107
- setResetTransformCallback(callback) {
108
- this.resetTransformCallback = callback;
109
- }
110
111
  notifyStateChange() {
111
112
  this.notifyListeners();
112
113
  }
@@ -184,93 +185,36 @@ class GestureViewerManager {
184
185
  this.translateX.set(withTiming(0));
185
186
  this.translateY.set(withTiming(0));
186
187
  };
187
- goToIndex = index => {
188
- if (!this.enableHorizontalSwipe || !this.listRef) {
189
- return;
190
- }
191
- this.cancelPendingLoopTransition();
192
- const {
193
- scrollTo
194
- } = createScrollAction(this.listRef, this.width);
195
- if (this.enableLoop && this.dataLength > 1) {
196
- if (index < 0) {
197
- this.loopCallback = () => {
198
- scrollTo(this.dataLength, false);
199
- this.updateCurrentIndex(this.dataLength - 1);
200
- this.cancelPendingLoopTransition();
201
- };
202
- this.resetTransformCallback?.();
203
- this.programmaticScrollVersion += 1;
204
- scrollTo(0, true);
205
- return;
206
- }
207
- if (index >= this.dataLength) {
208
- this.loopCallback = () => {
209
- scrollTo(1, false);
210
- this.updateCurrentIndex(0);
211
- this.cancelPendingLoopTransition();
212
- };
213
- this.resetTransformCallback?.();
214
- this.programmaticScrollVersion += 1;
215
- scrollTo(this.dataLength + 1, true);
216
- return;
217
- }
218
- this.resetTransformCallback?.();
219
- this.programmaticScrollVersion += 1;
220
- scrollTo(index + 1, true);
221
- this.updateCurrentIndex(index);
222
- return;
223
- }
224
- if (index < 0 || index >= this.dataLength) {
188
+ goToIndex = (index, options) => {
189
+ if (!this.navigationAdapter) {
225
190
  return;
226
191
  }
227
- this.resetTransformCallback?.();
228
- this.programmaticScrollVersion += 1;
229
- scrollTo(index, true);
230
- this.updateCurrentIndex(index);
231
- };
232
- handleMomentumScrollEnd = scrollIndex => {
233
- if (!this.loopCallback) {
234
- return false;
235
- }
236
- if (scrollIndex === 0 || scrollIndex === this.dataLength + 1) {
237
- this.loopCallback();
238
- return true;
239
- }
240
- this.cancelPendingLoopTransition();
241
- return true;
242
- };
243
- cancelPendingLoopTransition = () => {
244
- this.loopCallback = null;
245
- };
246
- handleScrollBeginDrag = () => {
247
- this.cancelPendingLoopTransition();
192
+ this.navigationAdapter.goToIndex(index, options);
248
193
  };
249
194
  goToPrevious = () => {
250
- this.goToIndex(this.currentIndex - 1);
195
+ if (!this.navigationAdapter) {
196
+ return;
197
+ }
198
+ this.navigationAdapter.goToPrevious();
251
199
  };
252
200
  goToNext = () => {
253
- this.goToIndex(this.currentIndex + 1);
201
+ if (!this.navigationAdapter) {
202
+ return;
203
+ }
204
+ this.navigationAdapter.goToNext();
254
205
  };
255
206
  cleanUp() {
256
- this.cancelPendingLoopTransition();
257
207
  this.listeners.clear();
258
- this.listRef = null;
259
- this.enableHorizontalSwipe = true;
260
- this.currentIndex = 0;
261
- this.dataLength = 0;
208
+ this.navigationAdapter = null;
209
+ this.stateReader = DEFAULT_STATE_READER;
262
210
  this.maxZoomScale = 2;
263
211
  this.scale = null;
264
212
  this.translateX = null;
265
213
  this.translateY = null;
266
214
  this.rotation = null;
267
- this.resetTransformCallback = null;
268
215
  this.eventListeners.clear();
216
+ this.eventListenerPresenceSubscribers.clear();
269
217
  }
270
- updateCurrentIndex = targetIndex => {
271
- this.currentIndex = targetIndex;
272
- this.notifyListeners();
273
- };
274
218
  }
275
219
  export default GestureViewerManager;
276
220
  //# sourceMappingURL=GestureViewerManager.js.map