Skip to content

Commit f184494

Browse files
committed
fix: dont start gesture if no steps or [0]
1 parent b20ae97 commit f184494

File tree

1 file changed

+17
-15
lines changed

1 file changed

+17
-15
lines changed

src/index.ts

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
HandlerType,
88
Manager,
99
PanGestureHandler,
10-
install as installGestures,
10+
install as installGestures
1111
} from '@nativescript-community/gesturehandler';
1212
import { Animation, AnimationDefinition, CSSType, Color, EventData, GridLayout, Property, ScrollEventData, ScrollView, TouchGestureEventData, Utils, View, booleanConverter } from '@nativescript/core';
1313
import { AnimationCurve } from '@nativescript/core/ui/enums';
@@ -37,34 +37,34 @@ export const scrollViewProperty = new Property<PersistentBottomSheet, string>({
3737
defaultValue: undefined,
3838
valueChanged: (target, oldValue, newValue) => {
3939
(target as any)._onScrollViewIdChanged(oldValue, newValue);
40-
},
40+
}
4141
});
4242
export const bottomSheetProperty = new Property<PersistentBottomSheet, View>({
4343
name: 'bottomSheet',
4444
defaultValue: undefined,
4545
valueChanged: (target, oldValue, newValue) => {
4646
(target as any)._onBottomSheetChanged(oldValue, newValue);
47-
},
47+
}
4848
});
4949
export const gestureEnabledProperty = new Property<PersistentBottomSheet, boolean>({
5050
name: 'gestureEnabled',
5151
defaultValue: true,
52-
valueConverter: booleanConverter,
52+
valueConverter: booleanConverter
5353
});
5454
export const stepsProperty = new Property<PersistentBottomSheet, number[]>({
5555
name: 'steps',
56-
defaultValue: [70],
56+
defaultValue: [70]
5757
});
5858
export const stepIndexProperty = new Property<PersistentBottomSheet, number>({
5959
name: 'stepIndex',
60-
defaultValue: 0,
60+
defaultValue: 0
6161
});
6262
export const backdropColorProperty = new Property<PersistentBottomSheet, Color>({
6363
name: 'backdropColor',
64-
valueConverter: (c) => (c ? new Color(c) : null),
64+
valueConverter: (c) => (c ? new Color(c) : null)
6565
});
6666
export const translationFunctionProperty = new Property<PersistentBottomSheet, Function>({
67-
name: 'translationFunction',
67+
name: 'translationFunction'
6868
});
6969

7070
@CSSType('PersistentBottomSheet')
@@ -119,7 +119,7 @@ export class PersistentBottomSheet extends GridLayout {
119119
simultaneousHandlers: [NATIVE_GESTURE_TAG],
120120
// shouldCancelWhenOutside: true,
121121
// activeOffsetX: this.leftSwipeDistance,
122-
minDist: SWIPE_DISTANCE_MINIMUM,
122+
minDist: SWIPE_DISTANCE_MINIMUM
123123
// failOffsetX: SWIPE_DISTANCE_MINIMUM,
124124
});
125125
gestureHandler.on(GestureHandlerTouchEvent, this.onGestureTouch, this);
@@ -128,6 +128,9 @@ export class PersistentBottomSheet extends GridLayout {
128128
this.panGestureHandler = gestureHandler as any;
129129
}
130130
protected shouldStartGesture(data) {
131+
if (this.steps.length === 0 || (this.steps.length === 1 && this.steps[0] === 0)) {
132+
return false;
133+
}
131134
const safeAreatop = Utils.layout.toDeviceIndependentPixels(this.getSafeAreaInsets().top);
132135
const y = data.y - safeAreatop;
133136
// console.log('shouldStartGesture ', safeAreatop, data, y, this.viewHeight - (this.translationMaxOffset - this.translationY), this.translationY, this.translationMaxOffset, this.viewHeight);
@@ -230,7 +233,6 @@ export class PersistentBottomSheet extends GridLayout {
230233
this.insertChild(this.backDrop, index);
231234
}
232235

233-
234236
get scrollView() {
235237
return this._scrollView;
236238
}
@@ -303,11 +305,11 @@ export class PersistentBottomSheet extends GridLayout {
303305
}
304306
return {
305307
bottomSheet: {
306-
translateY: value,
308+
translateY: value
307309
},
308310
backDrop: {
309-
opacity: progress,
310-
},
311+
opacity: progress
312+
}
311313
};
312314
}
313315
private onLayoutChange(event: EventData) {
@@ -518,7 +520,7 @@ export class PersistentBottomSheet extends GridLayout {
518520
return Object.assign(
519521
{
520522
curve: AnimationCurve.easeOut,
521-
duration,
523+
duration
522524
},
523525
transformAnimationValues(trData[k])
524526
);
@@ -527,7 +529,7 @@ export class PersistentBottomSheet extends GridLayout {
527529
{
528530
target: this[k],
529531
curve: AnimationCurve.easeOut,
530-
duration,
532+
duration
531533
},
532534
transformAnimationValues(trData[k])
533535
);

0 commit comments

Comments
 (0)