Skip to content

Commit

Permalink
fix: custom: lower TouchableWithoutFeedback to PaginationItem instead…
Browse files Browse the repository at this point in the history
…, re: #676
  • Loading branch information
nmassey authored and dohooo committed Oct 4, 2024
1 parent 1d22ee1 commit 5b30e17
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
9 changes: 7 additions & 2 deletions src/components/Pagination/Custom/PaginationItem.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { PropsWithChildren } from "react";
import React from "react";
import { TouchableWithoutFeedback } from "react-native";
import type { ViewStyle } from "react-native";
import type { SharedValue } from "react-native-reanimated";
import Animated, {
Expand Down Expand Up @@ -33,6 +34,7 @@ export const PaginationItem: React.FC<
horizontal?: boolean;
dotStyle?: DotStyle;
activeDotStyle?: DotStyle;
onPress: () => void;
customReanimatedStyle?: (
progress: number,
index: number,
Expand All @@ -51,6 +53,7 @@ export const PaginationItem: React.FC<
horizontal,
children,
customReanimatedStyle,
onPress,
} = props;
const customReanimatedStyleRef = useSharedValue<DefaultStyle>({});
const handleCustomAnimation = (progress: number) => {
Expand Down Expand Up @@ -130,6 +133,7 @@ export const PaginationItem: React.FC<
]);

return (
<TouchableWithoutFeedback onPress={onPress}>
<Animated.View
style={[
{
Expand All @@ -144,7 +148,8 @@ export const PaginationItem: React.FC<
animStyle,
]}
>
{children}
</Animated.View>
{children}
</Animated.View>
</TouchableWithoutFeedback>
);
};
13 changes: 5 additions & 8 deletions src/components/Pagination/Custom/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from "react";
import type { StyleProp, ViewStyle } from "react-native";
import { TouchableWithoutFeedback, View } from "react-native";
import { View } from "react-native";
import type { SharedValue } from "react-native-reanimated";

import type { DefaultStyle } from "react-native-reanimated/lib/typescript/reanimated2/hook/commonTypes";
Expand Down Expand Up @@ -80,23 +80,20 @@ export const Custom = <T extends {}>(props: ShapeProps<T>) => {
>
{data.map((item, index) => {
return (
<TouchableWithoutFeedback
key={index}
onPress={() => onPress?.(index)}
>
<PaginationItem
index={index}
key={index}
index={index}
size={size}
count={data.length}
dotStyle={dotStyle}
animValue={progress}
horizontal={!horizontal}
activeDotStyle={activeDotStyle}
customReanimatedStyle={customReanimatedStyle}
>
onPress={() => onPress?.(index)}
>
{renderItem?.(item, index)}
</PaginationItem>
</TouchableWithoutFeedback>
);
})}
</View>
Expand Down

0 comments on commit 5b30e17

Please sign in to comment.