react-native-reanimated-carousel 5.0.0 → 5.1.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.
- package/README.md +1 -1
- package/lib/commonjs/components/Pagination/PaginationItem.js +1 -1
- package/lib/commonjs/components/Pagination/PaginationItem.js.map +1 -1
- package/lib/commonjs/store/index.js.map +1 -1
- package/lib/commonjs/utils/computed-with-auto-fill-data.js.map +1 -1
- package/lib/module/components/Pagination/PaginationItem.js +1 -1
- package/lib/module/components/Pagination/PaginationItem.js.map +1 -1
- package/lib/module/store/index.js.map +1 -1
- package/lib/module/utils/computed-with-auto-fill-data.js.map +1 -1
- package/lib/typescript/commonjs/components/ItemLayout.d.ts +2 -2
- package/lib/typescript/commonjs/components/ItemLayout.d.ts.map +1 -1
- package/lib/typescript/commonjs/components/ItemRenderer.d.ts +3 -3
- package/lib/typescript/commonjs/components/ItemRenderer.d.ts.map +1 -1
- package/lib/typescript/commonjs/components/Pagination/PaginationItem.d.ts +4 -4
- package/lib/typescript/commonjs/components/Pagination/PaginationItem.d.ts.map +1 -1
- package/lib/typescript/commonjs/hooks/useCarouselController.d.ts +3 -3
- package/lib/typescript/commonjs/hooks/useCarouselController.d.ts.map +1 -1
- package/lib/typescript/commonjs/hooks/useOffsetX.d.ts +3 -3
- package/lib/typescript/commonjs/hooks/useOffsetX.d.ts.map +1 -1
- package/lib/typescript/commonjs/hooks/useOnProgressChange.d.ts +2 -2
- package/lib/typescript/commonjs/hooks/useOnProgressChange.d.ts.map +1 -1
- package/lib/typescript/commonjs/hooks/usePanGestureProxy.d.ts +2 -2
- package/lib/typescript/commonjs/hooks/usePanGestureProxy.d.ts.map +1 -1
- package/lib/typescript/commonjs/hooks/useUpdateGestureConfig.d.ts +1 -1
- package/lib/typescript/commonjs/hooks/useUpdateGestureConfig.d.ts.map +1 -1
- package/lib/typescript/commonjs/hooks/useVisibleRanges.d.ts +4 -4
- package/lib/typescript/commonjs/hooks/useVisibleRanges.d.ts.map +1 -1
- package/lib/typescript/commonjs/layouts/normal.d.ts +2 -2
- package/lib/typescript/commonjs/layouts/parallax.d.ts +6 -6
- package/lib/typescript/commonjs/public-types.d.ts +11 -1
- package/lib/typescript/commonjs/public-types.d.ts.map +1 -1
- package/lib/typescript/commonjs/store/index.d.ts +1 -1
- package/lib/typescript/commonjs/store/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/utils/carousel-math.d.ts +1 -1
- package/lib/typescript/commonjs/utils/carousel-math.d.ts.map +1 -1
- package/lib/typescript/module/components/ItemLayout.d.ts +2 -2
- package/lib/typescript/module/components/ItemLayout.d.ts.map +1 -1
- package/lib/typescript/module/components/ItemRenderer.d.ts +3 -3
- package/lib/typescript/module/components/ItemRenderer.d.ts.map +1 -1
- package/lib/typescript/module/components/Pagination/PaginationItem.d.ts +4 -4
- package/lib/typescript/module/components/Pagination/PaginationItem.d.ts.map +1 -1
- package/lib/typescript/module/hooks/useCarouselController.d.ts +3 -3
- package/lib/typescript/module/hooks/useCarouselController.d.ts.map +1 -1
- package/lib/typescript/module/hooks/useOffsetX.d.ts +3 -3
- package/lib/typescript/module/hooks/useOffsetX.d.ts.map +1 -1
- package/lib/typescript/module/hooks/useOnProgressChange.d.ts +2 -2
- package/lib/typescript/module/hooks/useOnProgressChange.d.ts.map +1 -1
- package/lib/typescript/module/hooks/usePanGestureProxy.d.ts +2 -2
- package/lib/typescript/module/hooks/usePanGestureProxy.d.ts.map +1 -1
- package/lib/typescript/module/hooks/useUpdateGestureConfig.d.ts +1 -1
- package/lib/typescript/module/hooks/useUpdateGestureConfig.d.ts.map +1 -1
- package/lib/typescript/module/hooks/useVisibleRanges.d.ts +4 -4
- package/lib/typescript/module/hooks/useVisibleRanges.d.ts.map +1 -1
- package/lib/typescript/module/layouts/normal.d.ts +2 -2
- package/lib/typescript/module/layouts/parallax.d.ts +6 -6
- package/lib/typescript/module/public-types.d.ts +11 -1
- package/lib/typescript/module/public-types.d.ts.map +1 -1
- package/lib/typescript/module/store/index.d.ts +1 -1
- package/lib/typescript/module/store/index.d.ts.map +1 -1
- package/lib/typescript/module/utils/carousel-math.d.ts +1 -1
- package/lib/typescript/module/utils/carousel-math.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/components/ItemLayout.tsx +2 -2
- package/src/components/ItemRenderer.tsx +3 -3
- package/src/components/Pagination/PaginationItem.tsx +9 -5
- package/src/hooks/useCarouselController.tsx +3 -3
- package/src/hooks/useOffsetX.ts +3 -3
- package/src/hooks/useOnProgressChange.ts +2 -2
- package/src/hooks/usePanGestureProxy.ts +7 -7
- package/src/hooks/useUpdateGestureConfig.ts +1 -1
- package/src/hooks/useVisibleRanges.tsx +4 -4
- package/src/public-types.ts +11 -0
- package/src/store/index.tsx +1 -1
- package/src/utils/carousel-math.ts +1 -1
- package/src/utils/computed-with-auto-fill-data.ts +2 -2
|
@@ -45,12 +45,12 @@ function interpolateDotColor(
|
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
export function PaginationItem(props: {
|
|
48
|
-
activeDotStyle?: PaginationDotStyle;
|
|
48
|
+
activeDotStyle?: PaginationDotStyle | undefined;
|
|
49
49
|
count: number;
|
|
50
|
-
dotStyle?: PaginationDotStyle;
|
|
50
|
+
dotStyle?: PaginationDotStyle | undefined;
|
|
51
51
|
index: number;
|
|
52
|
-
label?: string;
|
|
53
|
-
onPress?: (index: number) => void;
|
|
52
|
+
label?: string | undefined;
|
|
53
|
+
onPress?: ((index: number) => void) | undefined;
|
|
54
54
|
progress: PaginationProps["progress"];
|
|
55
55
|
}) {
|
|
56
56
|
const { activeDotStyle, count, dotStyle, index, label, onPress, progress } = props;
|
|
@@ -71,8 +71,12 @@ export function PaginationItem(props: {
|
|
|
71
71
|
const activeBackgroundColor = activeDotStyle?.backgroundColor ?? DEFAULT_ACTIVE_DOT_COLOR;
|
|
72
72
|
const activeOpacity = activeDotStyle?.opacity ?? baseOpacity;
|
|
73
73
|
|
|
74
|
+
// Lazy initializer: React only invokes it on the first render, which is
|
|
75
|
+
// exempt from Reanimated's "reading `value` during render" strict check.
|
|
76
|
+
// A plain expression would re-read `progress.value` on every re-render
|
|
77
|
+
// and trigger the warning (issue #940).
|
|
74
78
|
const [selected, setSelected] = React.useState(
|
|
75
|
-
count === 1 || getPaginationSelectedIndex(progress.value, count) === index
|
|
79
|
+
() => count === 1 || getPaginationSelectedIndex(progress.value, count) === index
|
|
76
80
|
);
|
|
77
81
|
|
|
78
82
|
useAnimatedReaction(
|
|
@@ -27,9 +27,9 @@ interface CarouselControllerOptions {
|
|
|
27
27
|
rawDataLength: number;
|
|
28
28
|
handlerOffset: SharedValue<number>;
|
|
29
29
|
animation: CarouselAnimation;
|
|
30
|
-
defaultIndex?: number;
|
|
31
|
-
onScrollStart?: () => void;
|
|
32
|
-
onMovementEnd?: (index: number) => void;
|
|
30
|
+
defaultIndex?: number | undefined;
|
|
31
|
+
onScrollStart?: (() => void) | undefined;
|
|
32
|
+
onMovementEnd?: ((index: number) => void) | undefined;
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
export interface CarouselController {
|
package/src/hooks/useOffsetX.ts
CHANGED
|
@@ -8,9 +8,9 @@ export interface OffsetOptions {
|
|
|
8
8
|
size: number;
|
|
9
9
|
handlerOffset: SharedValue<number>;
|
|
10
10
|
dataLength: number;
|
|
11
|
-
type?: "positive" | "negative";
|
|
12
|
-
viewCount?: number;
|
|
13
|
-
loop?: boolean;
|
|
11
|
+
type?: "positive" | "negative" | undefined;
|
|
12
|
+
viewCount?: number | undefined;
|
|
13
|
+
loop?: boolean | undefined;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
export const useOffsetX = (opts: OffsetOptions, visibleRanges: VisibleRangesValue) => {
|
|
@@ -8,8 +8,8 @@ import { getLogicalProgress } from "../utils/carousel-math";
|
|
|
8
8
|
export function useOnProgressChange(options: {
|
|
9
9
|
loop: boolean;
|
|
10
10
|
offset: SharedValue<number>;
|
|
11
|
-
onProgressChange?: CarouselProgressChangeHandler;
|
|
12
|
-
progress?: SharedValue<number
|
|
11
|
+
onProgressChange?: CarouselProgressChangeHandler | undefined;
|
|
12
|
+
progress?: SharedValue<number> | undefined;
|
|
13
13
|
rawDataLength: number;
|
|
14
14
|
size: number;
|
|
15
15
|
sizeReady: SharedValue<boolean>;
|
|
@@ -11,14 +11,14 @@ import type { GestureConfig } from "./useUpdateGestureConfig";
|
|
|
11
11
|
import { useUpdateGestureConfig } from "./useUpdateGestureConfig";
|
|
12
12
|
|
|
13
13
|
export const usePanGestureProxy = (customization: {
|
|
14
|
-
onConfigurePanGesture?: (gesture: CarouselPanGesture) => void;
|
|
14
|
+
onConfigurePanGesture?: ((gesture: CarouselPanGesture) => void) | undefined;
|
|
15
15
|
onGestureStart: (event: GestureStateChangeEvent<PanGestureHandlerEventPayload>) => void;
|
|
16
16
|
onGestureUpdate: (event: GestureUpdateEvent<PanGestureHandlerEventPayload>) => void;
|
|
17
17
|
onGestureEnd: (
|
|
18
18
|
event: GestureStateChangeEvent<PanGestureHandlerEventPayload>,
|
|
19
19
|
success: boolean
|
|
20
20
|
) => void;
|
|
21
|
-
options?: GestureConfig;
|
|
21
|
+
options?: GestureConfig | undefined;
|
|
22
22
|
}) => {
|
|
23
23
|
const {
|
|
24
24
|
onConfigurePanGesture,
|
|
@@ -42,11 +42,11 @@ export const usePanGestureProxy = (customization: {
|
|
|
42
42
|
|
|
43
43
|
// Save the user defined gesture callbacks
|
|
44
44
|
const userDefinedConflictGestures: {
|
|
45
|
-
onBegin
|
|
46
|
-
onStart
|
|
47
|
-
onUpdate
|
|
48
|
-
onEnd
|
|
49
|
-
onFinalize
|
|
45
|
+
onBegin: Parameters<(typeof gesture)["onBegin"]>[0] | undefined;
|
|
46
|
+
onStart: Parameters<(typeof gesture)["onStart"]>[0] | undefined;
|
|
47
|
+
onUpdate: Parameters<(typeof gesture)["onUpdate"]>[0] | undefined;
|
|
48
|
+
onEnd: Parameters<(typeof gesture)["onEnd"]>[0] | undefined;
|
|
49
|
+
onFinalize: Parameters<(typeof gesture)["onFinalize"]>[0] | undefined;
|
|
50
50
|
} = {
|
|
51
51
|
onBegin: undefined,
|
|
52
52
|
onStart: undefined,
|
|
@@ -27,9 +27,9 @@ function normalizeLoopIndex(currentIndex: number, total: number) {
|
|
|
27
27
|
|
|
28
28
|
export function computeVisibleRanges(params: {
|
|
29
29
|
total: number;
|
|
30
|
-
windowSize?: number;
|
|
30
|
+
windowSize?: number | undefined;
|
|
31
31
|
currentIndex: number;
|
|
32
|
-
loop?: boolean;
|
|
32
|
+
loop?: boolean | undefined;
|
|
33
33
|
}): VisibleRanges {
|
|
34
34
|
"worklet";
|
|
35
35
|
|
|
@@ -91,9 +91,9 @@ export function computeVisibleRanges(params: {
|
|
|
91
91
|
export function useVisibleRanges(options: {
|
|
92
92
|
total: number;
|
|
93
93
|
viewSize: number;
|
|
94
|
-
windowSize?: number;
|
|
94
|
+
windowSize?: number | undefined;
|
|
95
95
|
translation: SharedValue<number>;
|
|
96
|
-
loop?: boolean;
|
|
96
|
+
loop?: boolean | undefined;
|
|
97
97
|
}): VisibleRangesValue {
|
|
98
98
|
const { total = 0, viewSize, translation, windowSize: _windowSize, loop } = options;
|
|
99
99
|
|
package/src/public-types.ts
CHANGED
|
@@ -5,6 +5,7 @@ import type {
|
|
|
5
5
|
GestureType,
|
|
6
6
|
GestureUpdateEvent,
|
|
7
7
|
MouseButton,
|
|
8
|
+
PanGesture,
|
|
8
9
|
PanGestureChangeEventPayload,
|
|
9
10
|
PanGestureHandlerEventPayload,
|
|
10
11
|
PanGestureHandlerProps,
|
|
@@ -148,6 +149,16 @@ export type CarouselItemAnimation = (relativeProgress: number, index: number) =>
|
|
|
148
149
|
* methods such as `enabled`, `runOnJS`, or `manualActivation`.
|
|
149
150
|
*/
|
|
150
151
|
export interface CarouselPanGesture {
|
|
152
|
+
/**
|
|
153
|
+
* Controlled view of the underlying RNGH pan gesture configuration.
|
|
154
|
+
*
|
|
155
|
+
* Exposes the web-only `touchAction` option (e.g. `"pan-y"` so a
|
|
156
|
+
* horizontal carousel nested in a vertically scrollable page keeps native
|
|
157
|
+
* vertical scrolling on mobile web) without casting away the facade.
|
|
158
|
+
* Ownership-changing options such as `enabled`, `runOnJS`, or
|
|
159
|
+
* `manualActivation` intentionally stay hidden.
|
|
160
|
+
*/
|
|
161
|
+
readonly config: Pick<PanGesture["config"], "touchAction">;
|
|
151
162
|
activeOffsetX(offset: number | [start: number, end: number]): this;
|
|
152
163
|
activeOffsetY(offset: number | [start: number, end: number]): this;
|
|
153
164
|
failOffsetX(offset: number | [start: number, end: number]): this;
|
package/src/store/index.tsx
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
|
|
3
|
-
import { SharedValue, useSharedValue } from "react-native-reanimated";
|
|
3
|
+
import { type SharedValue, useSharedValue } from "react-native-reanimated";
|
|
4
4
|
import type { CarouselCommonVariables } from "../hooks/useCommonVariables";
|
|
5
5
|
import type { InitializedCarouselProps } from "../hooks/useInitProps";
|
|
6
6
|
|
|
@@ -82,9 +82,9 @@ export function computedFillDataWithAutoFillData<T>(
|
|
|
82
82
|
if (isAutoFillData({ loop, autoFillData })) {
|
|
83
83
|
switch (dataLength) {
|
|
84
84
|
case SINGLE_ITEM:
|
|
85
|
-
return [data[0]
|
|
85
|
+
return [data[0]!, data[0]!, data[0]!];
|
|
86
86
|
case DOUBLE_ITEM:
|
|
87
|
-
return [data[0]
|
|
87
|
+
return [data[0]!, data[1]!, data[0]!, data[1]!];
|
|
88
88
|
}
|
|
89
89
|
}
|
|
90
90
|
|