@@ -121,16 +121,10 @@ export class PersistentBottomSheet extends GridLayout {
121
121
// }
122
122
}
123
123
shouldStartGesture ( data ) {
124
- // if (this.scrollView) {
125
124
const safeAreatop = Utils . layout . toDeviceIndependentPixels ( this . getSafeAreaInsets ( ) . top ) ;
126
- // if (global.isIOS) {
127
- // // why do we get need :s
128
- // safeAreatop -= 10;
129
- // }
130
- // const y = data.y - safeAreatop;
131
125
const y = data . y - safeAreatop ;
132
126
// console.log('shouldStartGesture ', safeAreatop, data, y, this.viewHeight - (this.translationMaxOffset - this.translationY), this.translationY, this.translationMaxOffset, this.viewHeight);
133
- if ( y < this . viewHeight - ( this . translationMaxOffset - this . translationY ) ) {
127
+ if ( y < this . viewHeight - ( this . bottomViewHeight - this . translationY ) ) {
134
128
return false ;
135
129
}
136
130
if ( this . _scrollView ) {
@@ -282,7 +276,7 @@ export class PersistentBottomSheet extends GridLayout {
282
276
newValue . iosOverflowSafeAreaEnabled = false ;
283
277
newValue . verticalAlignment = 'bottom' ;
284
278
newValue . on ( 'layoutChanged' , this . onBottomLayoutChange , this ) ;
285
- let index ;
279
+ let index ;
286
280
if ( ! newValue . parent ) {
287
281
index = this . getChildrenCount ( ) ;
288
282
this . addChild ( newValue ) ;
@@ -299,8 +293,11 @@ export class PersistentBottomSheet extends GridLayout {
299
293
}
300
294
301
295
computeTranslationData ( height ) {
296
+ const max = this . translationMaxOffset ;
297
+ const diff = height - max ;
302
298
const value = this . _translationY ;
303
- const progress = 1 - value / height ;
299
+ const progress = 1 - ( this . _translationY - diff ) / max ;
300
+ // console.log('computeTranslationData', value, max, diff, progress);
304
301
if ( this . translationFunction ) {
305
302
return this . translationFunction ( height , value , progress ) ;
306
303
}
@@ -418,7 +415,7 @@ export class PersistentBottomSheet extends GridLayout {
418
415
// const viewY = this.translationY - height;
419
416
const y = touchY - ( this . lastTouchY || touchY ) ;
420
417
const trY = this . constrainY ( this . translationY + y ) ;
421
- const height = this . translationMaxOffset ;
418
+ const height = this . bottomViewHeight ;
422
419
// console.log('constraining on touch event', touchY, this.lastTouchY, y, trY);
423
420
this . translationY = trY ;
424
421
const trData = this . computeTranslationData ( height ) ;
@@ -456,22 +453,24 @@ export class PersistentBottomSheet extends GridLayout {
456
453
}
457
454
458
455
computeAndAnimateEndGestureAnimation ( totalDelta : number ) {
459
- const viewHeight = this . translationMaxOffset ;
456
+ const viewHeight = this . bottomViewHeight ;
460
457
const steps = this . steps ;
461
458
let stepIndex = 0 ;
462
459
let destSnapPoint = viewHeight - steps [ stepIndex ] ;
460
+ let distance = Math . abs ( destSnapPoint - totalDelta ) ;
463
461
for ( let i = 0 ; i < steps . length ; i ++ ) {
464
462
const snapPoint = viewHeight - steps [ i ] ;
465
463
const distFromSnap = Math . abs ( snapPoint - totalDelta ) ;
466
464
if ( distFromSnap <= Math . abs ( destSnapPoint - totalDelta ) ) {
467
465
destSnapPoint = snapPoint ;
468
466
stepIndex = i ;
467
+ distance = distFromSnap ;
469
468
}
470
469
}
471
470
// stepIndexProperty.nativeValueChange
472
471
// this.stepIndex = stepIndex;
473
472
stepIndexProperty . nativeValueChange ( this , stepIndex ) ;
474
- this . animateToPosition ( viewHeight - destSnapPoint ) ;
473
+ this . animateToPosition ( viewHeight - destSnapPoint , Math . min ( distance , OPEN_DURATION ) ) ;
475
474
}
476
475
onGestureTouch ( args : GestureTouchEventData ) {
477
476
const data = args . data ;
@@ -485,8 +484,9 @@ export class PersistentBottomSheet extends GridLayout {
485
484
}
486
485
const y = deltaY - this . prevDeltaY ;
487
486
const trY = this . constrainY ( this . translationY + y ) ;
487
+ console . log ( this . translationY , y , trY ) ;
488
488
this . translationY = trY ;
489
- const height = this . translationMaxOffset ;
489
+ const height = this . bottomViewHeight ;
490
490
const trData = this . computeTranslationData ( height ) ;
491
491
this . applyTrData ( trData ) ;
492
492
this . prevDeltaY = deltaY ;
@@ -505,7 +505,7 @@ export class PersistentBottomSheet extends GridLayout {
505
505
}
506
506
507
507
constrainY ( y ) {
508
- return Math . max ( Math . min ( y , this . translationMaxOffset ) , 0 ) ;
508
+ return Math . max ( Math . min ( y , this . bottomViewHeight ) , this . bottomViewHeight - this . translationMaxOffset ) ;
509
509
}
510
510
511
511
async animateToPosition ( position , duration = OPEN_DURATION ) {
0 commit comments