Skip to content

Commit 3fb9242

Browse files
authored
feat: enabledBottomInitialAnimation prop added (#148)
1 parent 187e300 commit 3fb9242

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@ class Example extends React.Component {
6767
| enabledContentGestureInteraction | no | `true` | Defines if bottom sheet content could be scrollable by gesture. |
6868
| enabledContentTapInteraction | no | `true` | Defines whether bottom sheet content could be tapped. |
6969
| enabledManualSnapping | no | `true` | If `false` blocks snapping using `snapTo` method. |
70-
| enabledBottomClamp | no | `false` | If `true` block movement is clamped from bottom to minimal snappoint. |
70+
| enabledBottomClamp | no | `false` | If `true` block movement is clamped from bottom to minimal snapPoint. |
71+
| enabledBottomInitialAnimation | no | `false` | If `true` sheet will grows up from bottom to initial snapPoint. |
7172
| enabledInnerScrolling | no | `true` | Defines whether it's possible to scroll inner content of bottom sheet. |
7273
| callbackNode | no | | `reanimated` node which holds position of bottom sheet, where `0` it the highest snap point and `1` is the lowest. |
7374
| contentPosition | no | | `reanimated` node which holds position of bottom sheet's content (in dp) |

src/index.tsx

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@ type Props = {
4646
*/
4747
enabledBottomClamp?: boolean
4848

49+
/**
50+
* When true, sheet will grows up from bottom to initial snapPoint.
51+
*/
52+
enabledBottomInitialAnimation?: boolean
53+
4954
/**
5055
* If false blocks snapping using snapTo method. Defaults to true.
5156
*/
@@ -293,6 +298,7 @@ export default class BottomSheetBehavior extends React.Component<Props, State> {
293298
enabledImperativeSnapping: true,
294299
enabledGestureInteraction: true,
295300
enabledBottomClamp: false,
301+
enabledBottomInitialAnimation: false,
296302
enabledHeaderGestureInteraction: true,
297303
enabledContentGestureInteraction: true,
298304
enabledContentTapInteraction: true,
@@ -725,10 +731,19 @@ export default class BottomSheetBehavior extends React.Component<Props, State> {
725731

726732
const { initialSnap } = props
727733

734+
let init =
735+
sortedPropsSnapPoints[0].val -
736+
sortedPropsSnapPoints[propsToNewIndices[initialSnap]].val
737+
738+
if (props.enabledBottomInitialAnimation) {
739+
init =
740+
sortedPropsSnapPoints[
741+
sortedPropsSnapPoints.length - 1 - propsToNewIndices[initialSnap]
742+
].val
743+
}
744+
728745
return {
729-
init:
730-
sortedPropsSnapPoints[0].val -
731-
sortedPropsSnapPoints[propsToNewIndices[initialSnap]].val,
746+
init,
732747
propsToNewIndices,
733748
heightOfHeaderAnimated:
734749
(state && state.heightOfHeaderAnimated) || new Value(0),

0 commit comments

Comments
 (0)