Skip to content

Commit

Permalink
fix: refactor export statements in main file
Browse files Browse the repository at this point in the history
  • Loading branch information
hancandice committed May 21, 2024
1 parent 3bc90c4 commit 72889d1
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-native-reanimated-zoomable",
"version": "0.2.1",
"version": "0.2.2",
"description": "[React Native | TypeScript | Reanimated] Pure TS component that offers zooming and dragging functionalities for its child components. It seamlessly operates on both Android and iOS platforms.",
"main": "lib/commonjs/index",
"module": "lib/module/index",
Expand Down Expand Up @@ -157,6 +157,6 @@
]
},
"dependencies": {
"react-native-reanimated": "^3.11.0"
"react-native-reanimated": "^2.0.0"
}
}
12 changes: 6 additions & 6 deletions src/components/Zoomable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,17 @@ import Animated, {
useAnimatedStyle,
useSharedValue,
withTiming,
type AnimateStyle,
type AnimatedStyleProp,
} from 'react-native-reanimated';
import { AnimatedView } from 'react-native-reanimated/lib/typescript/reanimated2/component/View';
import { isAndroid } from '../utils/platform';

export interface ZoomableRef {
setValues(_: { scale?: number; translate?: { x: number; y: number } }): void;
}

type ZoomableProps = PropsWithChildren<{
style?: ViewStyle;
style?: AnimateStyle<ViewStyle>;
initialScale?: number;
maxScale?: number;
threshold?: number;
Expand Down Expand Up @@ -90,7 +91,7 @@ const Zoomable = (
const translateX = useSharedValue<number>(0);
const translateY = useSharedValue<number>(0);

const containerView = useRef<AnimatedView>();
const containerView = useRef<Animated.View>();
const layout = useRef<Layout>();
const lastTransform = useRef({
scale: initialScale,
Expand Down Expand Up @@ -220,7 +221,6 @@ const Zoomable = (
if (disablePanResponderReleaseAction) {
return;
}

if (isZoom.current) {
// if it was a zoom gesture, do not trigger any animation
isZoom.current = false;
Expand Down Expand Up @@ -294,7 +294,7 @@ const Zoomable = (
{ translateY: translateY.value },
{ scale: scale.value },
],
};
} as AnimatedStyleProp<ViewStyle>;
}, [scale, translateX, translateY]);

useImperativeHandle(ref, () => ({
Expand Down Expand Up @@ -330,7 +330,7 @@ const Zoomable = (
return (
<Animated.View
ref={(zoomableViewRef) => {
containerView.current = zoomableViewRef as AnimatedView;
containerView.current = zoomableViewRef as Animated.View;
}}
style={[style, style?.transform ? {} : animStyle]}
{...panResponder?.panHandlers}
Expand Down
3 changes: 1 addition & 2 deletions src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { Zoomable, type ZoomableRef } from './components/Zoomable';

export default Zoomable;
export type { ZoomableRef };
export { Zoomable, type ZoomableRef };

0 comments on commit 72889d1

Please sign in to comment.