Skip to content

Commit 804dc5b

Browse files
committed
Export inner gesture handler refs
1 parent 225ff78 commit 804dc5b

File tree

3 files changed

+16
-10
lines changed

3 files changed

+16
-10
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ class Example extends React.Component {
6868
| callbackNode | no | | `reanimated` node which holds position of bottom sheet, where `0` it the highest snap point and `1` is the lowest. |
6969
| overdragResistanceFactor | no | 0 | `Defines how violently sheet has to stopped while overdragging. 0 means no overdrag |
7070
| springConfig | no | `{ }` | Overrides config for spring animation |
71+
| 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. |
7172

7273

7374
## Methods

index.js

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ export default class BottomSheetBehavior extends Component {
117117
enabledGestureInteraction: true,
118118
enabledInnerScrolling: true,
119119
springConfig: {},
120+
innerGestureHandlerRefs: [ React.createRef(), React.createRef(), React.createRef() ],
120121
};
121122

122123
decayClock = new Clock();
@@ -134,6 +135,9 @@ export default class BottomSheetBehavior extends Component {
134135

135136
constructor(props) {
136137
super(props)
138+
this.panRef = props.innerGestureHandlerRefs[0]
139+
this.master = props.innerGestureHandlerRefs[1]
140+
this.tapRef = props.innerGestureHandlerRefs[2]
137141
this.state = BottomSheetBehavior.getDerivedStateFromProps(props)
138142
const { snapPoints, init } = this.state
139143
const middlesOfSnapPoints = []
@@ -315,8 +319,6 @@ export default class BottomSheetBehavior extends Component {
315319
])
316320
}
317321

318-
panRef = React.createRef();
319-
320322
snapTo = index => {
321323
if (!this.props.enabledImperativeSnapping) {
322324
return
@@ -395,17 +397,16 @@ export default class BottomSheetBehavior extends Component {
395397
}
396398
}
397399

398-
master = React.createRef();
399-
400400
render() {
401401
return (
402402
<React.Fragment>
403-
<Animated.View style={{
404-
height: '100%',
405-
width: 0,
406-
position: 'absolute'
407-
}}
408-
onLayout={this.handleFullHeader}
403+
<Animated.View
404+
style={{
405+
height: '100%',
406+
width: 0,
407+
position: 'absolute'
408+
}}
409+
onLayout={this.handleFullHeader}
409410
/>
410411
<Animated.View style={{
411412
width: '100%',
@@ -451,6 +452,7 @@ export default class BottomSheetBehavior extends Component {
451452
>
452453
<Animated.View>
453454
<TapGestureHandler
455+
ref={this.tapRef}
454456
enabled={this.props.enabledGestureInteraction}
455457
onHandlerStateChange={this.handleTap}
456458
>

reanimated-bottom-sheet.d.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ declare module 'reanimated-bottom-sheet' {
3232

3333
/** Overrides config for spring animation */
3434
springConfig?: object;
35+
36+
/** Refs for gesture handlers used for building bottomsheet */
37+
innerGestureHandlerRefs: object[]
3538
}
3639

3740
export default class BottomSheet extends React.Component<BottomSheetProps> {

0 commit comments

Comments
 (0)