@@ -4,28 +4,31 @@ import {
4
4
GestureState ,
5
5
GestureStateEventData ,
6
6
GestureTouchEventData ,
7
- HandlerType , install as installGestures , Manager ,
7
+ HandlerType ,
8
+ Manager ,
8
9
PanGestureHandler ,
9
- PanGestureHandlerOptions
10
+ PanGestureHandlerOptions ,
11
+ install as installGestures
10
12
} from '@nativescript-community/gesturehandler' ;
11
13
import {
12
14
AbsoluteLayout ,
13
15
Animation ,
14
- AnimationDefinition , booleanConverter , Color ,
15
- CoreTypes , CSSType , EventData ,
16
+ AnimationDefinition ,
17
+ CSSType ,
18
+ Color ,
19
+ CoreTypes ,
20
+ EventData ,
16
21
GridLayout ,
17
22
Property ,
18
23
ScrollEventData ,
19
24
ScrollView ,
20
25
TouchGestureEventData ,
21
26
Utils ,
22
- View
27
+ View ,
28
+ booleanConverter
23
29
} from '@nativescript/core' ;
24
30
const OPEN_DURATION = 200 ;
25
- const CLOSE_DURATION = 200 ;
26
31
export let PAN_GESTURE_TAG = 12400 ;
27
- // export const NATIVE_GESTURE_TAG = 12421;
28
- const DEFAULT_TRIGGER_WIDTH = 20 ;
29
32
const SWIPE_DISTANCE_MINIMUM = 10 ;
30
33
31
34
function transformAnimationValues ( values ) {
@@ -121,7 +124,7 @@ export class PersistentBottomSheet extends AbsoluteLayout {
121
124
}
122
125
123
126
// nativeGestureHandler: PanGestureHandler;
124
- translationFunction ?: ( height : number , delta : number , progress : number ) => { bottomSheet ?: AnimationDefinition ; backDrop ?: AnimationDefinition } ;
127
+ translationFunction ?: ( delta : number , max : number , progress : number ) => { bottomSheet ?: AnimationDefinition ; backDrop ?: AnimationDefinition } ;
125
128
protected initGestures ( ) {
126
129
const manager = Manager . getInstance ( ) ;
127
130
const options = { gestureId : PAN_GESTURE_TAG ++ , ...this . panGestureOptions } ;
@@ -219,7 +222,11 @@ export class PersistentBottomSheet extends AbsoluteLayout {
219
222
}
220
223
}
221
224
protected addBackdropView ( index : number ) {
222
- this . backDrop = new GridLayout ( ) ;
225
+ this . backDrop = new AbsoluteLayout ( ) ;
226
+ this . backDrop . width = this . backDrop . height = {
227
+ unit : '%' ,
228
+ value : 100
229
+ } ;
223
230
this . backDrop . backgroundColor = this . backdropColor ;
224
231
this . backDrop . opacity = 0 ;
225
232
this . backDrop . isUserInteractionEnabled = false ;
@@ -297,18 +304,17 @@ export class PersistentBottomSheet extends AbsoluteLayout {
297
304
}
298
305
}
299
306
300
- computeTranslationData ( ty ) {
307
+ computeTranslationData ( ) {
301
308
const max = this . translationMaxOffset ;
302
309
let value = this . _translationY ;
303
- const diff = max - ty ;
304
- const progress = ty / max ;
310
+ const progress = - value / max ;
305
311
if ( __IOS__ && progress === 0 && ! this . iosIgnoreSafeArea ) {
306
312
// if this is the 0 steop ensure it gets hidden even with safeArea
307
313
const safeArea = this . getSafeAreaInsets ( ) ;
308
314
value += Utils . layout . toDeviceIndependentPixels ( safeArea . bottom ) ;
309
315
}
310
316
if ( this . translationFunction ) {
311
- return this . translationFunction ( ty , value , progress ) ;
317
+ return this . translationFunction ( value , max , progress ) ;
312
318
}
313
319
return {
314
320
bottomSheet : {
@@ -334,7 +340,7 @@ export class PersistentBottomSheet extends AbsoluteLayout {
334
340
const step = steps [ this . stepIndex ] ;
335
341
const ty = step ;
336
342
this . translationY = - ty ;
337
- const data = this . computeTranslationData ( ty ) ;
343
+ const data = this . computeTranslationData ( ) ;
338
344
this . applyTrData ( data ) ;
339
345
}
340
346
}
@@ -400,7 +406,7 @@ export class PersistentBottomSheet extends AbsoluteLayout {
400
406
const y = touchY - ( this . lastTouchY || touchY ) ;
401
407
const trY = this . constrainY ( this . translationY + y ) ;
402
408
this . translationY = trY ;
403
- const trData = this . computeTranslationData ( - trY ) ;
409
+ const trData = this . computeTranslationData ( ) ;
404
410
this . applyTrData ( trData ) ;
405
411
}
406
412
this . lastTouchY = touchY ;
@@ -462,7 +468,7 @@ export class PersistentBottomSheet extends AbsoluteLayout {
462
468
const y = deltaY - this . prevDeltaY ;
463
469
const trY = this . constrainY ( this . translationY + y ) ;
464
470
this . translationY = trY ;
465
- const trData = this . computeTranslationData ( - trY ) ;
471
+ const trData = this . computeTranslationData ( ) ;
466
472
this . applyTrData ( trData ) ;
467
473
this . prevDeltaY = deltaY ;
468
474
}
@@ -502,7 +508,7 @@ export class PersistentBottomSheet extends AbsoluteLayout {
502
508
}
503
509
// const height = this.bottomViewHeight;
504
510
this . translationY = - position ;
505
- const trData = this . computeTranslationData ( position ) ;
511
+ const trData = this . computeTranslationData ( ) ;
506
512
const params = Object . keys ( trData )
507
513
. map ( ( k ) => {
508
514
const data = trData [ k ] ;
0 commit comments