Skip to content

Commit db80164

Browse files
itsyogeshosdnk
authored andcommitted
feat: Add a new headerPosition prop (#59)
Added a new headerPosition prop that returns the reanimated node to keep track of the current location of the header (in dp). The reason to add this is in reference to issue #54 where I needed to find the current location to implement the said UI functionality.
1 parent 43de165 commit db80164

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ class Example extends React.Component {
6767
| enabledInnerScrolling | no | `true` | Defines whether it's possible to scroll inner content of bottom sheet. |
6868
| callbackNode | no | | `reanimated` node which holds position of bottom sheet, where `0` it the highest snap point and `1` is the lowest. |
6969
| contentPosition | no | | `reanimated` node which holds position of bottom sheet's content (in dp) |
70+
| headerPosition | no | | `reanimated` node which holds position of bottom sheet's header (in dp) |
7071
| overdragResistanceFactor | no | 0 | `Defines how violently sheet has to stopped while overdragging. 0 means no overdrag |
7172
| springConfig | no | `{ }` | Overrides config for spring animation |
7273
| innerGestureHandlerRefs | no | | Refs for gesture handlers used for building bottom sheet. The array consists fo three refs. The first for PanGH used for inner content scrolling. The second for PanGH used for header. The third for TapGH used for stopping scrolling the content. |

src/index.tsx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,11 @@ type Props = {
5454
*/
5555
contentPosition?: Animated.Value<number>
5656

57+
/**
58+
* Reanimated node which holds position of bottom sheet's header (in dp).
59+
*/
60+
headerPosition?: Animated.Value<number>
61+
5762
/**
5863
* Defines how violently sheet has to stopped while overdragging. 0 means no overdrag. Defaults to 0.
5964
*/
@@ -777,6 +782,14 @@ export default class BottomSheetBehavior extends React.Component<Props, State> {
777782
)}
778783
/>
779784
)}
785+
{this.props.headerPosition && (
786+
<Animated.Code
787+
exec={onChange(
788+
this.translateMaster,
789+
set(this.props.headerPosition, this.translateMaster)
790+
)}
791+
/>
792+
)}
780793
</View>
781794
</Animated.View>
782795
</React.Fragment>

0 commit comments

Comments
 (0)