react-native-gesture-image-viewer 2.1.3 → 2.1.4
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/lib/module/GestureViewer.js +50 -40
- package/lib/module/GestureViewer.js.map +1 -1
- package/lib/module/GestureViewerManager.js +26 -6
- package/lib/module/GestureViewerManager.js.map +1 -1
- package/lib/module/useGestureViewer.js +67 -86
- package/lib/module/useGestureViewer.js.map +1 -1
- package/lib/module/useGestureViewerPaging.js +68 -0
- package/lib/module/useGestureViewerPaging.js.map +1 -0
- package/lib/module/useGestureViewerPaging.types.js +4 -0
- package/lib/module/useGestureViewerPaging.types.js.map +1 -0
- package/lib/module/useGestureViewerPaging.web.js +241 -0
- package/lib/module/useGestureViewerPaging.web.js.map +1 -0
- package/lib/module/utils/index.js +9 -0
- package/lib/module/utils/index.js.map +1 -1
- package/lib/module/utils/tapZoom.js +34 -0
- package/lib/module/utils/tapZoom.js.map +1 -0
- package/lib/module/utils/webScroll.js +70 -0
- package/lib/module/utils/webScroll.js.map +1 -0
- package/lib/typescript/src/GestureViewer.d.ts.map +1 -1
- package/lib/typescript/src/GestureViewerManager.d.ts +5 -0
- package/lib/typescript/src/GestureViewerManager.d.ts.map +1 -1
- package/lib/typescript/src/useGestureViewer.d.ts +4 -3
- package/lib/typescript/src/useGestureViewer.d.ts.map +1 -1
- package/lib/typescript/src/useGestureViewerPaging.d.ts +3 -0
- package/lib/typescript/src/useGestureViewerPaging.d.ts.map +1 -0
- package/lib/typescript/src/useGestureViewerPaging.types.d.ts +32 -0
- package/lib/typescript/src/useGestureViewerPaging.types.d.ts.map +1 -0
- package/lib/typescript/src/useGestureViewerPaging.web.d.ts +3 -0
- package/lib/typescript/src/useGestureViewerPaging.web.d.ts.map +1 -0
- package/lib/typescript/src/utils/index.d.ts +7 -0
- package/lib/typescript/src/utils/index.d.ts.map +1 -1
- package/lib/typescript/src/utils/tapZoom.d.ts +12 -0
- package/lib/typescript/src/utils/tapZoom.d.ts.map +1 -0
- package/lib/typescript/src/utils/webScroll.d.ts +18 -0
- package/lib/typescript/src/utils/webScroll.d.ts.map +1 -0
- package/package.json +1 -1
- package/src/GestureViewer.tsx +39 -15
- package/src/GestureViewerManager.ts +29 -6
- package/src/useGestureViewer.ts +71 -139
- package/src/useGestureViewerPaging.ts +112 -0
- package/src/useGestureViewerPaging.types.ts +34 -0
- package/src/useGestureViewerPaging.web.ts +390 -0
- package/src/utils/index.ts +17 -1
- package/src/utils/tapZoom.ts +44 -0
- package/src/utils/webScroll.ts +96 -0
|
@@ -13,7 +13,9 @@ declare class GestureViewerManager {
|
|
|
13
13
|
private rotation;
|
|
14
14
|
private translateX;
|
|
15
15
|
private translateY;
|
|
16
|
+
private resetTransformCallback;
|
|
16
17
|
private loopCallback;
|
|
18
|
+
private programmaticScrollVersion;
|
|
17
19
|
private listeners;
|
|
18
20
|
private eventListeners;
|
|
19
21
|
private notifyListeners;
|
|
@@ -23,6 +25,7 @@ declare class GestureViewerManager {
|
|
|
23
25
|
emitZoomChange: (scale: number, previousScale: number | null) => void;
|
|
24
26
|
emitRotationChange: (rotation: number, previousRotation: number | null) => void;
|
|
25
27
|
getState(): GestureViewerState;
|
|
28
|
+
getProgrammaticScrollVersion(): number;
|
|
26
29
|
setEnableLoop(enabled: boolean): void;
|
|
27
30
|
setWidth(width: number): void;
|
|
28
31
|
setHeight(height: number): void;
|
|
@@ -31,6 +34,7 @@ declare class GestureViewerManager {
|
|
|
31
34
|
setEnableHorizontalSwipe(enabled: boolean): void;
|
|
32
35
|
setCurrentIndex(index: number): void;
|
|
33
36
|
setZoomSharedValues(scale: SharedValue<number>, translateX: SharedValue<number>, translateY: SharedValue<number>, maxZoomScale: number): void;
|
|
37
|
+
setResetTransformCallback(callback: (() => void) | null): void;
|
|
34
38
|
notifyStateChange(): void;
|
|
35
39
|
setRotation(rotation: SharedValue<number>): void;
|
|
36
40
|
rotate: (angle?: 0 | 90 | 180 | 270 | 360, clockwise?: boolean) => void;
|
|
@@ -39,6 +43,7 @@ declare class GestureViewerManager {
|
|
|
39
43
|
resetZoom: (scale?: number) => void;
|
|
40
44
|
goToIndex: (index: number) => void;
|
|
41
45
|
handleMomentumScrollEnd: (scrollIndex: number) => boolean;
|
|
46
|
+
cancelPendingLoopTransition: () => void;
|
|
42
47
|
handleScrollBeginDrag: () => void;
|
|
43
48
|
goToPrevious: () => void;
|
|
44
49
|
goToNext: () => 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;AAEvE,OAAO,KAAK,EACV,0BAA0B,EAE1B,sBAAsB,EACtB,kBAAkB,EACnB,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,qBAAqB,CAAQ;IACrC,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;
|
|
1
|
+
{"version":3,"file":"GestureViewerManager.d.ts","sourceRoot":"","sources":["../../../src/GestureViewerManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,WAAW,EAAc,MAAM,yBAAyB,CAAC;AAEvE,OAAO,KAAK,EACV,0BAA0B,EAE1B,sBAAsB,EACtB,kBAAkB,EACnB,MAAM,SAAS,CAAC;AAGjB,cAAM,oBAAoB;IACxB,OAAO,CAAC,YAAY,CAAK;IACzB,OAAO,CAAC,U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UAAU,EAAE,WAAW,CAAC,MAAM,CAAC,EAC/B,UAAU,EAAE,WAAW,CAAC,MAAM,CAAC,EAC/B,YAAY,EAAE,MAAM;IAQtB,yBAAyB,CAAC,QAAQ,EAAE,CAAC,MAAM,IAAI,CAAC,GAAG,IAAI;IAIvD,iBAAiB;IAIjB,WAAW,CAAC,QAAQ,EAAE,WAAW,CAAC,MAAM,CAAC;IAIzC,MAAM,GAAI,QAAO,CAAC,GAAG,EAAE,GAAG,GAAG,GAAG,GAAG,GAAG,GAAQ,EAAE,mBAAgB,UA6B9D;IAEF,MAAM,GAAI,mBAAiB,UA0BzB;IAEF,OAAO,GAAI,mBAAiB,UAgC1B;IAEF,SAAS,GAAI,cAAS,UAcpB;IAEF,SAAS,GAAI,OAAO,MAAM,UAoDxB;IAEF,uBAAuB,GAAI,aAAa,MAAM,aAY5C;IAEF,2BAA2B,aAEzB;IAEF,qBAAqB,aAEnB;IAEF,YAAY,aAEV;IAEF,QAAQ,aAEN;IAEF,OAAO;IAgBP,OAAO,CAAC,kBAAkB,CAGxB;CACH;AAED,eAAe,oBAAoB,CAAC"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { type NativeScrollEvent, type NativeSyntheticEvent } from 'react-native';
|
|
2
1
|
import type { GestureViewerProps } from './types';
|
|
3
2
|
type UseGestureViewerProps<ItemT, LC> = Omit<GestureViewerProps<ItemT, LC>, 'renderItem' | 'renderContainer' | 'ListComponent' | 'listProps' | 'containerStyle' | 'backdropStyle' | 'enableSnapMode'>;
|
|
4
3
|
export declare const useGestureViewer: <ItemT, LC>({ data, initialIndex, onDismiss, width: customWidth, dismiss, enableDoubleTapZoom, enablePinchZoom, enableHorizontalSwipe, enablePanWhenZoomed, enableLoop, maxZoomScale, itemSpacing, height: customHeight, id, onDismissStart, triggerAnimation, autoPlay, autoPlayInterval, }: UseGestureViewerProps<ItemT, LC>) => {
|
|
@@ -37,8 +36,10 @@ export declare const useGestureViewer: <ItemT, LC>({ data, initialIndex, onDismi
|
|
|
37
36
|
isZoomed: boolean;
|
|
38
37
|
listRef: import("react").RefObject<any>;
|
|
39
38
|
nativeScrollGesture: import("react-native-gesture-handler/lib/typescript/handlers/gestures/nativeGesture").NativeGesture;
|
|
40
|
-
|
|
41
|
-
|
|
39
|
+
onWebDoubleClick: ((event: any) => void) | undefined;
|
|
40
|
+
onMomentumScrollEnd: ((event: import("react-native").NativeSyntheticEvent<import("react-native").NativeScrollEvent>) => void) | undefined;
|
|
41
|
+
onScroll: ((event: import("react-native").NativeSyntheticEvent<import("react-native").NativeScrollEvent>) => void) | undefined;
|
|
42
|
+
onScrollBeginDrag: ((event: import("react-native").NativeSyntheticEvent<import("react-native").NativeScrollEvent>) => void) | undefined;
|
|
42
43
|
zoomGesture: import("react-native-gesture-handler/lib/typescript/handlers/gestures/gestureComposition").ComposedGesture;
|
|
43
44
|
};
|
|
44
45
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useGestureViewer.d.ts","sourceRoot":"","sources":["../../../src/useGestureViewer.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useGestureViewer.d.ts","sourceRoot":"","sources":["../../../src/useGestureViewer.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,kBAAkB,EAAe,MAAM,SAAS,CAAC;AAK/D,KAAK,qBAAqB,CAAC,KAAK,EAAE,EAAE,IAAI,IAAI,CAC1C,kBAAkB,CAAC,KAAK,EAAE,EAAE,CAAC,EAC3B,YAAY,GACZ,iBAAiB,GACjB,eAAe,GACf,WAAW,GACX,gBAAgB,GAChB,eAAe,GACf,gBAAgB,CACnB,CAAC;AAEF,eAAO,MAAM,gBAAgB,GAAI,KAAK,EAAE,EAAE,EAAE,kRAmBzC,qBAAqB,CAAC,KAAK,EAAE,EAAE,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4mBlC,CAAC"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { UseGestureViewerPagingArgs, UseGestureViewerPagingResult } from './useGestureViewerPaging.types';
|
|
2
|
+
export declare function useGestureViewerPaging({ autoPlay, autoPlayInterval, currentIndex, dataLength, enableHorizontalSwipe, enableLoop, isRotated, isZoomed, itemSpacing, manager, scrollTo, syncCurrentIndex, width, }: UseGestureViewerPagingArgs): UseGestureViewerPagingResult;
|
|
3
|
+
//# sourceMappingURL=useGestureViewerPaging.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useGestureViewerPaging.d.ts","sourceRoot":"","sources":["../../../src/useGestureViewerPaging.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,0BAA0B,EAC1B,4BAA4B,EAC7B,MAAM,gCAAgC,CAAC;AAGxC,wBAAgB,sBAAsB,CAAC,EACrC,QAAQ,EACR,gBAAgB,EAChB,YAAY,EACZ,UAAU,EACV,qBAAqB,EACrB,UAAU,EACV,SAAS,EACT,QAAQ,EACR,WAAW,EACX,OAAO,EACP,QAAQ,EACR,gBAAgB,EAChB,KAAK,GACN,EAAE,0BAA0B,GAAG,4BAA4B,CAwF3D"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { ScrollViewProps } from 'react-native';
|
|
2
|
+
import type { SharedValue } from 'react-native-reanimated';
|
|
3
|
+
import type GestureViewerManager from './GestureViewerManager';
|
|
4
|
+
export type UseGestureViewerPagingArgs = {
|
|
5
|
+
adjustedInitialIndex: number;
|
|
6
|
+
autoPlay: boolean;
|
|
7
|
+
autoPlayInterval: number;
|
|
8
|
+
currentIndex: number;
|
|
9
|
+
dataLength: number;
|
|
10
|
+
enableDoubleTapZoom: boolean;
|
|
11
|
+
enableHorizontalSwipe: boolean;
|
|
12
|
+
enableLoop: boolean;
|
|
13
|
+
height: number;
|
|
14
|
+
isRotated: boolean;
|
|
15
|
+
isZoomed: boolean;
|
|
16
|
+
itemSpacing: number;
|
|
17
|
+
manager: GestureViewerManager | null;
|
|
18
|
+
maxZoomScale: number;
|
|
19
|
+
scale: SharedValue<number>;
|
|
20
|
+
scrollTo: (index: number, animated: boolean) => void;
|
|
21
|
+
syncCurrentIndex: (nextIndex: number) => void;
|
|
22
|
+
translateX: SharedValue<number>;
|
|
23
|
+
translateY: SharedValue<number>;
|
|
24
|
+
width: number;
|
|
25
|
+
};
|
|
26
|
+
export type UseGestureViewerPagingResult = {
|
|
27
|
+
onMomentumScrollEnd?: ScrollViewProps['onMomentumScrollEnd'];
|
|
28
|
+
onScroll?: ScrollViewProps['onScroll'];
|
|
29
|
+
onScrollBeginDrag?: ScrollViewProps['onScrollBeginDrag'];
|
|
30
|
+
onWebDoubleClick?: (event: any) => void;
|
|
31
|
+
};
|
|
32
|
+
//# sourceMappingURL=useGestureViewerPaging.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useGestureViewerPaging.types.d.ts","sourceRoot":"","sources":["../../../src/useGestureViewerPaging.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAE3D,OAAO,KAAK,oBAAoB,MAAM,wBAAwB,CAAC;AAE/D,MAAM,MAAM,0BAA0B,GAAG;IACvC,oBAAoB,EAAE,MAAM,CAAC;IAC7B,QAAQ,EAAE,OAAO,CAAC;IAClB,gBAAgB,EAAE,MAAM,CAAC;IACzB,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,mBAAmB,EAAE,OAAO,CAAC;IAC7B,qBAAqB,EAAE,OAAO,CAAC;IAC/B,UAAU,EAAE,OAAO,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,OAAO,CAAC;IACnB,QAAQ,EAAE,OAAO,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,oBAAoB,GAAG,IAAI,CAAC;IACrC,YAAY,EAAE,MAAM,CAAC;IACrB,KAAK,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAC3B,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,KAAK,IAAI,CAAC;IACrD,gBAAgB,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;IAC9C,UAAU,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAChC,UAAU,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAChC,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,4BAA4B,GAAG;IACzC,mBAAmB,CAAC,EAAE,eAAe,CAAC,qBAAqB,CAAC,CAAC;IAC7D,QAAQ,CAAC,EAAE,eAAe,CAAC,UAAU,CAAC,CAAC;IACvC,iBAAiB,CAAC,EAAE,eAAe,CAAC,mBAAmB,CAAC,CAAC;IACzD,gBAAgB,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,IAAI,CAAC;CACzC,CAAC"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { UseGestureViewerPagingArgs, UseGestureViewerPagingResult } from './useGestureViewerPaging.types';
|
|
2
|
+
export declare function useGestureViewerPaging({ adjustedInitialIndex, autoPlay, autoPlayInterval, currentIndex, dataLength, enableDoubleTapZoom, enableHorizontalSwipe, enableLoop, height, isRotated, isZoomed, itemSpacing, manager, maxZoomScale, scale, scrollTo, syncCurrentIndex, translateX, translateY, width, }: UseGestureViewerPagingArgs): UseGestureViewerPagingResult;
|
|
3
|
+
//# sourceMappingURL=useGestureViewerPaging.web.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useGestureViewerPaging.web.d.ts","sourceRoot":"","sources":["../../../src/useGestureViewerPaging.web.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,0BAA0B,EAC1B,4BAA4B,EAC7B,MAAM,gCAAgC,CAAC;AAqBxC,wBAAgB,sBAAsB,CAAC,EACrC,oBAAoB,EACpB,QAAQ,EACR,gBAAgB,EAChB,YAAY,EACZ,UAAU,EACV,mBAAmB,EACnB,qBAAqB,EACrB,UAAU,EACV,MAAM,EACN,SAAS,EACT,QAAQ,EACR,WAAW,EACX,OAAO,EACP,YAAY,EACZ,KAAK,EACL,QAAQ,EACR,gBAAgB,EAChB,UAAU,EACV,UAAU,EACV,KAAK,GACN,EAAE,0BAA0B,GAAG,4BAA4B,CAqV3D"}
|
|
@@ -1,7 +1,14 @@
|
|
|
1
|
+
import { type PlatformOSType } from 'react-native';
|
|
1
2
|
import type { FlatListComponent, ScrollViewComponent } from '../types';
|
|
2
3
|
export declare const isScrollViewLike: (component: React.ComponentType<any>) => component is ScrollViewComponent;
|
|
3
4
|
export declare const isFlatListLike: (component: React.ComponentType<any>) => component is FlatListComponent<any>;
|
|
4
5
|
export declare const isFlashListLike: (component: React.ComponentType<any>) => boolean;
|
|
6
|
+
/**
|
|
7
|
+
* iOS needs the extra Native gesture wrapper so the dismiss pan can resolve before the scrollable claims touches.
|
|
8
|
+
* We intentionally skip Android because the same require-to-fail relation regressed horizontal paging there,
|
|
9
|
+
* and we also avoid wrapping RNGH-provided scrollables to prevent double-applying Gesture.Native() to components that already participate in RNGH.
|
|
10
|
+
*/
|
|
11
|
+
export declare const shouldUseNativeScrollGesture: (platformOS: PlatformOSType, component: React.ComponentType<any>) => boolean;
|
|
5
12
|
export declare const createBoundsConstraint: ({ width, height }: {
|
|
6
13
|
width: number;
|
|
7
14
|
height: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/utils/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,cAAc,EACpB,MAAM,cAAc,CAAC;AAMtB,OAAO,KAAK,EAAE,iBAAiB,EAAE,mBAAmB,EA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oomAtPoint: ({ x, y, width, height, maxZoomScale, scale, translateX, translateY, }: {
|
|
3
|
+
x: number;
|
|
4
|
+
y: number;
|
|
5
|
+
width: number;
|
|
6
|
+
height: number;
|
|
7
|
+
maxZoomScale: number;
|
|
8
|
+
scale: SharedValue<number>;
|
|
9
|
+
translateX: SharedValue<number>;
|
|
10
|
+
translateY: SharedValue<number>;
|
|
11
|
+
}) => void;
|
|
12
|
+
//# sourceMappingURL=tapZoom.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tapZoom.d.ts","sourceRoot":"","sources":["../../../../src/utils/tapZoom.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAG3D,eAAO,MAAM,mBAAmB,GAAI,uEASjC;IACD,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,MAAM,CAAC;IACrB,KAAK,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAC3B,UAAU,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAChC,UAAU,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;CACjC,SAsBA,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export declare const getWebScrollPhysicalIndex: (offsetX: number, pageWidth: number) => number;
|
|
2
|
+
export declare const resolveWebScrollFinalState: ({ dataLength, enableLoop, lastSettledPhysicalIndex, offsetX, pageWidth, }: {
|
|
3
|
+
offsetX: number;
|
|
4
|
+
pageWidth: number;
|
|
5
|
+
lastSettledPhysicalIndex: number;
|
|
6
|
+
dataLength: number;
|
|
7
|
+
enableLoop: boolean;
|
|
8
|
+
}) => {
|
|
9
|
+
logicalIndex: number;
|
|
10
|
+
rawPhysicalIndex: number;
|
|
11
|
+
settledPhysicalIndex: number;
|
|
12
|
+
} | null;
|
|
13
|
+
export declare const getWebAutoPlayTargetPhysicalIndex: ({ currentIndex, dataLength, enableLoop, }: {
|
|
14
|
+
currentIndex: number;
|
|
15
|
+
dataLength: number;
|
|
16
|
+
enableLoop: boolean;
|
|
17
|
+
}) => number | null;
|
|
18
|
+
//# sourceMappingURL=webScroll.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webScroll.d.ts","sourceRoot":"","sources":["../../../../src/utils/webScroll.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,yBAAyB,GAAI,SAAS,MAAM,EAAE,WAAW,MAAM,KAAG,MAM9E,CAAC;AAEF,eAAO,MAAM,0BAA0B,GAAI,2EAMxC;IACD,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,wBAAwB,EAAE,MAAM,CAAC;IACjC,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,OAAO,CAAC;CACrB,KAAG;IAAE,YAAY,EAAE,MAAM,CAAC;IAAC,gBAAgB,EAAE,MAAM,CAAC;IAAC,oBAAoB,EAAE,MAAM,CAAA;CAAE,GAAG,IAiDtF,CAAC;AAEF,eAAO,MAAM,iCAAiC,GAAI,2CAI/C;IACD,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,OAAO,CAAC;CACrB,KAAG,MAAM,GAAG,IAgBZ,CAAC"}
|
package/package.json
CHANGED
package/src/GestureViewer.tsx
CHANGED
|
@@ -12,7 +12,13 @@ import Animated from 'react-native-reanimated';
|
|
|
12
12
|
import { registry } from './GestureViewerRegistry';
|
|
13
13
|
import type { GestureViewerProps } from './types';
|
|
14
14
|
import { useGestureViewer } from './useGestureViewer';
|
|
15
|
-
import {
|
|
15
|
+
import {
|
|
16
|
+
createLoopData,
|
|
17
|
+
isFlashListLike,
|
|
18
|
+
isFlatListLike,
|
|
19
|
+
isScrollViewLike,
|
|
20
|
+
shouldUseNativeScrollGesture,
|
|
21
|
+
} from './utils';
|
|
16
22
|
import WebPagingFixStyle from './WebPagingFixStyle';
|
|
17
23
|
|
|
18
24
|
export function GestureViewer<ItemT, LC>({
|
|
@@ -53,7 +59,9 @@ export function GestureViewer<ItemT, LC>({
|
|
|
53
59
|
dismissGesture,
|
|
54
60
|
zoomGesture,
|
|
55
61
|
nativeScrollGesture,
|
|
62
|
+
onWebDoubleClick,
|
|
56
63
|
onMomentumScrollEnd,
|
|
64
|
+
onScroll,
|
|
57
65
|
onScrollBeginDrag,
|
|
58
66
|
animatedStyle,
|
|
59
67
|
backdropStyle,
|
|
@@ -130,7 +138,8 @@ export function GestureViewer<ItemT, LC>({
|
|
|
130
138
|
horizontal: true,
|
|
131
139
|
scrollEnabled: !isZoomed && !isRotated && !isPinching,
|
|
132
140
|
showsHorizontalScrollIndicator: false,
|
|
133
|
-
onMomentumScrollEnd
|
|
141
|
+
onMomentumScrollEnd,
|
|
142
|
+
onScroll,
|
|
134
143
|
onScrollBeginDrag,
|
|
135
144
|
...(enableSnapMode
|
|
136
145
|
? {
|
|
@@ -151,6 +160,7 @@ export function GestureViewer<ItemT, LC>({
|
|
|
151
160
|
isRotated,
|
|
152
161
|
isPinching,
|
|
153
162
|
onMomentumScrollEnd,
|
|
163
|
+
onScroll,
|
|
154
164
|
onScrollBeginDrag,
|
|
155
165
|
enableSnapMode,
|
|
156
166
|
],
|
|
@@ -158,6 +168,22 @@ export function GestureViewer<ItemT, LC>({
|
|
|
158
168
|
|
|
159
169
|
const control = useMemo(() => ({ dismiss: handleDismiss }), [handleDismiss]);
|
|
160
170
|
|
|
171
|
+
const shouldWrapScrollableWithNativeGesture = shouldUseNativeScrollGesture(
|
|
172
|
+
Platform.OS,
|
|
173
|
+
Component,
|
|
174
|
+
);
|
|
175
|
+
|
|
176
|
+
const maybeWrapWithNativeScrollGesture = useCallback(
|
|
177
|
+
(children: React.ReactNode) => {
|
|
178
|
+
if (!shouldWrapScrollableWithNativeGesture) {
|
|
179
|
+
return children;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
return <GestureDetector gesture={nativeScrollGesture}>{children}</GestureDetector>;
|
|
183
|
+
},
|
|
184
|
+
[nativeScrollGesture, shouldWrapScrollableWithNativeGesture],
|
|
185
|
+
);
|
|
186
|
+
|
|
161
187
|
const listComponent = (
|
|
162
188
|
<GestureHandlerRootView>
|
|
163
189
|
<GestureDetector gesture={gesture}>
|
|
@@ -165,18 +191,18 @@ export function GestureViewer<ItemT, LC>({
|
|
|
165
191
|
<Animated.View style={[styles.background, backdropStyleProps, backdropStyle]} />
|
|
166
192
|
<Animated.View
|
|
167
193
|
style={[styles.content, animatedStyle]}
|
|
194
|
+
{...(Platform.OS === 'web' && { onClick: onWebDoubleClick })}
|
|
168
195
|
{...(Platform.OS === 'web' &&
|
|
169
196
|
isFlashListLike(Component) && { dataSet: { 'flash-list-paging-enabled-fix': true } })}
|
|
170
197
|
>
|
|
171
|
-
{isScrollView
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
<GestureDetector gesture={nativeScrollGesture}>
|
|
198
|
+
{isScrollView
|
|
199
|
+
? maybeWrapWithNativeScrollGesture(
|
|
200
|
+
<Component ref={listRef} {...commonProps} {...listProps}>
|
|
201
|
+
{loopData.map((item, index) => renderItem({ item, index }))}
|
|
202
|
+
</Component>,
|
|
203
|
+
)
|
|
204
|
+
: isFlatListLike(Component) &&
|
|
205
|
+
maybeWrapWithNativeScrollGesture(
|
|
180
206
|
<Component
|
|
181
207
|
ref={listRef}
|
|
182
208
|
{...commonProps}
|
|
@@ -196,10 +222,8 @@ export function GestureViewer<ItemT, LC>({
|
|
|
196
222
|
dataSet: { 'flat-list-paging-enabled-fix': true },
|
|
197
223
|
})}
|
|
198
224
|
{...listProps}
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
)
|
|
202
|
-
)}
|
|
225
|
+
/>,
|
|
226
|
+
)}
|
|
203
227
|
</Animated.View>
|
|
204
228
|
<WebPagingFixStyle Component={Component} />
|
|
205
229
|
</View>
|
|
@@ -22,8 +22,10 @@ class GestureViewerManager {
|
|
|
22
22
|
private rotation: SharedValue<number> | null = null;
|
|
23
23
|
private translateX: SharedValue<number> | null = null;
|
|
24
24
|
private translateY: SharedValue<number> | null = null;
|
|
25
|
+
private resetTransformCallback: (() => void) | null = null;
|
|
25
26
|
|
|
26
27
|
private loopCallback: (() => void) | null = null;
|
|
28
|
+
private programmaticScrollVersion = 0;
|
|
27
29
|
|
|
28
30
|
private listeners = new Set<(state: GestureViewerState) => void>();
|
|
29
31
|
private eventListeners = new Map<GestureViewerEventType, Set<(data: any) => void>>();
|
|
@@ -91,6 +93,10 @@ class GestureViewerManager {
|
|
|
91
93
|
};
|
|
92
94
|
}
|
|
93
95
|
|
|
96
|
+
getProgrammaticScrollVersion() {
|
|
97
|
+
return this.programmaticScrollVersion;
|
|
98
|
+
}
|
|
99
|
+
|
|
94
100
|
setEnableLoop(enabled: boolean) {
|
|
95
101
|
this.enableLoop = enabled;
|
|
96
102
|
}
|
|
@@ -133,6 +139,10 @@ class GestureViewerManager {
|
|
|
133
139
|
this.maxZoomScale = maxZoomScale;
|
|
134
140
|
}
|
|
135
141
|
|
|
142
|
+
setResetTransformCallback(callback: (() => void) | null) {
|
|
143
|
+
this.resetTransformCallback = callback;
|
|
144
|
+
}
|
|
145
|
+
|
|
136
146
|
notifyStateChange() {
|
|
137
147
|
this.notifyListeners();
|
|
138
148
|
}
|
|
@@ -255,7 +265,7 @@ class GestureViewerManager {
|
|
|
255
265
|
return;
|
|
256
266
|
}
|
|
257
267
|
|
|
258
|
-
this.
|
|
268
|
+
this.cancelPendingLoopTransition();
|
|
259
269
|
|
|
260
270
|
const { scrollTo } = createScrollAction(this.listRef, this.width);
|
|
261
271
|
|
|
@@ -264,9 +274,11 @@ class GestureViewerManager {
|
|
|
264
274
|
this.loopCallback = () => {
|
|
265
275
|
scrollTo(this.dataLength, false);
|
|
266
276
|
this.updateCurrentIndex(this.dataLength - 1);
|
|
267
|
-
this.
|
|
277
|
+
this.cancelPendingLoopTransition();
|
|
268
278
|
};
|
|
269
279
|
|
|
280
|
+
this.resetTransformCallback?.();
|
|
281
|
+
this.programmaticScrollVersion += 1;
|
|
270
282
|
scrollTo(0, true);
|
|
271
283
|
return;
|
|
272
284
|
}
|
|
@@ -275,13 +287,17 @@ class GestureViewerManager {
|
|
|
275
287
|
this.loopCallback = () => {
|
|
276
288
|
scrollTo(1, false);
|
|
277
289
|
this.updateCurrentIndex(0);
|
|
278
|
-
this.
|
|
290
|
+
this.cancelPendingLoopTransition();
|
|
279
291
|
};
|
|
280
292
|
|
|
293
|
+
this.resetTransformCallback?.();
|
|
294
|
+
this.programmaticScrollVersion += 1;
|
|
281
295
|
scrollTo(this.dataLength + 1, true);
|
|
282
296
|
return;
|
|
283
297
|
}
|
|
284
298
|
|
|
299
|
+
this.resetTransformCallback?.();
|
|
300
|
+
this.programmaticScrollVersion += 1;
|
|
285
301
|
scrollTo(index + 1, true);
|
|
286
302
|
this.updateCurrentIndex(index);
|
|
287
303
|
|
|
@@ -292,6 +308,8 @@ class GestureViewerManager {
|
|
|
292
308
|
return;
|
|
293
309
|
}
|
|
294
310
|
|
|
311
|
+
this.resetTransformCallback?.();
|
|
312
|
+
this.programmaticScrollVersion += 1;
|
|
295
313
|
scrollTo(index, true);
|
|
296
314
|
this.updateCurrentIndex(index);
|
|
297
315
|
};
|
|
@@ -306,14 +324,18 @@ class GestureViewerManager {
|
|
|
306
324
|
return true;
|
|
307
325
|
}
|
|
308
326
|
|
|
309
|
-
this.
|
|
327
|
+
this.cancelPendingLoopTransition();
|
|
310
328
|
return true;
|
|
311
329
|
};
|
|
312
330
|
|
|
313
|
-
|
|
331
|
+
cancelPendingLoopTransition = () => {
|
|
314
332
|
this.loopCallback = null;
|
|
315
333
|
};
|
|
316
334
|
|
|
335
|
+
handleScrollBeginDrag = () => {
|
|
336
|
+
this.cancelPendingLoopTransition();
|
|
337
|
+
};
|
|
338
|
+
|
|
317
339
|
goToPrevious = () => {
|
|
318
340
|
this.goToIndex(this.currentIndex - 1);
|
|
319
341
|
};
|
|
@@ -323,7 +345,7 @@ class GestureViewerManager {
|
|
|
323
345
|
};
|
|
324
346
|
|
|
325
347
|
cleanUp() {
|
|
326
|
-
this.
|
|
348
|
+
this.cancelPendingLoopTransition();
|
|
327
349
|
this.listeners.clear();
|
|
328
350
|
this.listRef = null;
|
|
329
351
|
this.enableHorizontalSwipe = true;
|
|
@@ -334,6 +356,7 @@ class GestureViewerManager {
|
|
|
334
356
|
this.translateX = null;
|
|
335
357
|
this.translateY = null;
|
|
336
358
|
this.rotation = null;
|
|
359
|
+
this.resetTransformCallback = null;
|
|
337
360
|
this.eventListeners.clear();
|
|
338
361
|
}
|
|
339
362
|
|