Ver Fonte

Feature: Text.

lfabl há 2 meses atrás
pai
commit
4abb70f78d
2 ficheiros alterados com 17 adições e 3 exclusões
  1. 2 2
      example/src/index.tsx
  2. 15 1
      src/components/bottomSheet/index.tsx

+ 2 - 2
example/src/index.tsx

@@ -68,12 +68,12 @@ const App = () => {
         />
         <BottomSheet
             isCanFullScreenOnSwipe={true}
-            snapPoint={300}
+            // snapPoint={300}
         >
             <View
                 style={{
                     backgroundColor: "red",
-                    height: 2700
+                    height: 400
                 }}
             />
             <Text>Deneme 123</Text>

+ 15 - 1
src/components/bottomSheet/index.tsx

@@ -72,7 +72,7 @@ const BottomSheet: FC<IBottomSheetProps> = ({
 
     const scrollViewRef = useRef<ComponentRef<ScrollView>>(null);
 
-    const animatedTranslateY = useRef(new Animated.Value(0)).current;
+    const animatedTranslateY = useRef(new Animated.Value(snapPoint && !isWorkAsFullScreen ? snapPoint : windowHeight)).current;
     const animatedHeight = useRef(new Animated.Value(
         isAutoHeight ? 0 : snapPoint ?? 0
     )).current;
@@ -115,6 +115,7 @@ const BottomSheet: FC<IBottomSheetProps> = ({
         }) => {
             translateYValue.current = value;
         });
+        openAnimation();
 
         return () => {
             animatedHeight.removeListener(listenerAHeightId);
@@ -122,6 +123,19 @@ const BottomSheet: FC<IBottomSheetProps> = ({
         };
     }, []);
 
+    const openAnimation = () => {
+        Animated.spring(animatedTranslateY, {
+            useNativeDriver: false,
+            friction: 10,
+            tension: 40,
+            toValue: 0
+        }).start();
+    };
+
+    const closeAnimation = () => {
+
+    };
+
     const onLayout = (event: LayoutChangeEvent) => {
         if (isMeasured) return;