Skip to content

Commit

Permalink
chore: updated animated position prop
Browse files Browse the repository at this point in the history
  • Loading branch information
gorhom committed Aug 3, 2020
1 parent b8954d2 commit 2a1695b
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions src/components/bottomSheet/BottomSheet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import Animated, {
sub,
timing,
Value,
defined,
} from 'react-native-reanimated';
import {
PanGestureHandler,
Expand Down Expand Up @@ -163,6 +164,7 @@ export class BottomSheet extends Component<BottomSheetProps> {
/**
* Animated value that keeps track of the position: 0 => closed, 1 => opened
*/
// @ts-ignore
private position: Animated.Node<number>;
/**
* Flag to indicate imperative snapping
Expand Down Expand Up @@ -567,6 +569,18 @@ export class BottomSheet extends Component<BottomSheetProps> {
},
]}
>
<Animated.Code
exec={cond(defined(this.props.animatedPosition), [
cond(
eq(this.props.animatedPosition!, -1),
set(this.props.animatedPosition!, this.translateY)
),
onChange(
this.translateY,
set(this.props.animatedPosition!, this.translateY)
),
])}
/>
<PanGestureHandler
ref={this.drawerHandleRef}
shouldCancelWhenOutside={false}
Expand All @@ -592,14 +606,6 @@ export class BottomSheet extends Component<BottomSheetProps> {
>
{children}
</BottomSheetInternalProvider>
{this.props.animatedPosition && (
<Animated.Code
exec={onChange(
this.position,
set(this.props.animatedPosition, this.position)
)}
/>
)}
<Animated.Code
exec={onChange(
this.dragY,
Expand Down

0 comments on commit 2a1695b

Please sign in to comment.