Skip to content

Commit a14dce0

Browse files
committed
fix: allow to customize gesture options
1 parent 81adc03 commit a14dce0

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/index.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
HandlerType,
88
Manager,
99
PanGestureHandler,
10+
PanGestureHandlerOptions,
1011
install as installGestures
1112
} from '@nativescript-community/gesturehandler';
1213
import { Animation, AnimationDefinition, CSSType, Color, EventData, GridLayout, Property, ScrollEventData, ScrollView, TouchGestureEventData, Utils, View, booleanConverter } from '@nativescript/core';
@@ -94,6 +95,8 @@ export class PersistentBottomSheet extends GridLayout {
9495
private _isScrollEnabled = true;
9596
private scrollViewAtTop: boolean = true;
9697

98+
public panGestureOptions: PanGestureHandlerOptions & { gestureId?: number };
99+
97100
constructor() {
98101
super();
99102
this.isPassThroughParentEnabled = true;
@@ -112,15 +115,12 @@ export class PersistentBottomSheet extends GridLayout {
112115
translationFunction?: (height: number, delta: number, progress: number) => { bottomSheet?: AnimationDefinition; backDrop?: AnimationDefinition };
113116
protected initGestures() {
114117
const manager = Manager.getInstance();
115-
const gestureHandler = manager.createGestureHandler(HandlerType.PAN, PAN_GESTURE_TAG, {
118+
const options = { gestureId: PAN_GESTURE_TAG, ...this.panGestureOptions };
119+
const gestureHandler = manager.createGestureHandler(HandlerType.PAN, options.gestureId, {
116120
shouldStartGesture: this.shouldStartGesture.bind(this),
117-
// waitFor: [NATIVE_GESTURE_TAG],
118-
// disallowInterruption: true,
119121
simultaneousHandlers: [NATIVE_GESTURE_TAG],
120-
// shouldCancelWhenOutside: true,
121-
// activeOffsetX: this.leftSwipeDistance,
122-
minDist: SWIPE_DISTANCE_MINIMUM
123-
// failOffsetX: SWIPE_DISTANCE_MINIMUM,
122+
minDist: SWIPE_DISTANCE_MINIMUM,
123+
...options
124124
});
125125
gestureHandler.on(GestureHandlerTouchEvent, this.onGestureTouch, this);
126126
gestureHandler.on(GestureHandlerStateEvent, this.onGestureState, this);

0 commit comments

Comments
 (0)