-
-
Notifications
You must be signed in to change notification settings - Fork 154
Open
Description
It would be nice to expose animatedPosition (translateY), made a patch for it:
diff --git a/dist/src/index.js b/dist/src/index.js
index 69bcc4fe1eed936c9d7bdf6110eea4028608a9bb..d26c28d072e64feea5b01652494c5298fb2c0382 100644
--- a/dist/src/index.js
+++ b/dist/src/index.js
@@ -91,7 +91,7 @@ export default forwardRef(function ActionSheet(_a, ref) {
mass: 4,
stiffness: 900,
overshootClamping: true,
- } : _1, onRequestClose = _a.onRequestClose, props = __rest(_a, ["animated", "closeOnPressBack", "springOffset", "elevation", "disableElevation", "defaultOverlayOpacity", "overlayColor", "closable", "closeOnTouchBackdrop", "onTouchBackdrop", "drawUnderStatusBar", "gestureEnabled", "isModal", "snapPoints", "initialSnapIndex", "overdrawEnabled", "overdrawFactor", "overdrawSize", "zIndex", "keyboardHandlerEnabled", "ExtraOverlayComponent", "returnValue", "routes", "initialRoute", "onBeforeShow", "enableRouterBackNavigation", "onBeforeClose", "enableGesturesInScrollView", "disableDragBeyondMinimumSnapPoint", "useBottomSafeAreaPadding", "initialTranslateFactor", "openAnimationConfig", "onRequestClose"]);
+ } : _1, onRequestClose = _a.onRequestClose, animatedPosition = _a.animatedPosition, props = __rest(_a, ["animated", "closeOnPressBack", "springOffset", "elevation", "disableElevation", "defaultOverlayOpacity", "overlayColor", "closable", "closeOnTouchBackdrop", "onTouchBackdrop", "drawUnderStatusBar", "gestureEnabled", "isModal", "snapPoints", "initialSnapIndex", "overdrawEnabled", "overdrawFactor", "overdrawSize", "zIndex", "keyboardHandlerEnabled", "ExtraOverlayComponent", "returnValue", "routes", "initialRoute", "onBeforeShow", "enableRouterBackNavigation", "onBeforeClose", "enableGesturesInScrollView", "disableDragBeyondMinimumSnapPoint", "useBottomSafeAreaPadding", "initialTranslateFactor", "openAnimationConfig", "onRequestClose", "animatedPosition"]);
snapPoints =
snapPoints[snapPoints.length - 1] !== 100
? __spreadArray(__spreadArray([], snapPoints, true), [100], false) : snapPoints;
@@ -153,6 +153,21 @@ export default forwardRef(function ActionSheet(_a, ref) {
var opacity = useSharedValue(0);
var actionSheetOpacity = useSharedValue(1);
var translateY = useSharedValue(Dimensions.get('window').height * 2);
+ // Sync animatedPosition with translateY
+ useEffect(function () {
+ if (!animatedPosition) return;
+ var animatedPositionListenerId = 266787;
+ runOnUI(function () {
+ translateY.addListener(animatedPositionListenerId, function (value) {
+ animatedPosition.value = value;
+ });
+ })();
+ return function () {
+ runOnUI(function (listenerId) {
+ translateY.removeListener(listenerId);
+ })(animatedPositionListenerId);
+ };
+ }, [animatedPosition]);
var underlayTranslateY = useSharedValue(130);
var routeOpacity = useSharedValue(0);
var router = useRouter({
diff --git a/dist/src/types.d.ts b/dist/src/types.d.ts
index 713ff980b19140814e87a9d09b2f950113d898f3..aba56707240664a4dbe2512a2a4c282652eef68b 100644
--- a/dist/src/types.d.ts
+++ b/dist/src/types.d.ts
@@ -1,5 +1,6 @@
import React from 'react';
import { GestureResponderEvent, LayoutRectangle, PressableProps, StyleProp, ViewStyle } from 'react-native';
+import { SharedValue } from 'react-native-reanimated';
import { SpringConfig } from 'react-native-reanimated/lib/typescript/animation/springUtils';
import EventManager from './eventmanager';
import { Route } from './hooks/use-router';
@@ -367,6 +368,11 @@ export type ActionSheetProps<SheetId extends keyof Sheets = never> = {
* sheet to go beyond minimum snap point position with drag.
*/
disableDragBeyondMinimumSnapPoint?: boolean;
+ /**
+ * Animated value to be used as a callback for the position node internally.
+ * Use this for pixel-perfect animations synchronized with the sheet.
+ */
+ animatedPosition?: SharedValue<number>;
/**
* Called when the ActionSheet is closing based on some user actions:
*
Metadata
Metadata
Assignees
Labels
No labels