@@ -94,7 +94,7 @@ export class PersistentBottomSheet extends GridLayout {
94
94
initGestures ( ) {
95
95
const manager = Manager . getInstance ( ) ;
96
96
const gestureHandler = manager . createGestureHandler ( HandlerType . PAN , PAN_GESTURE_TAG , {
97
- shouldStartGesture : ( data ) => this . shouldStartGesture ( data ) ,
97
+ shouldStartGesture : this . shouldStartGesture . bind ( this ) ,
98
98
// waitFor: [NATIVE_GESTURE_TAG],
99
99
// disallowInterruption: true,
100
100
simultaneousHandlers : [ NATIVE_GESTURE_TAG ] ,
@@ -114,26 +114,19 @@ export class PersistentBottomSheet extends GridLayout {
114
114
shouldStartGesture ( data ) {
115
115
// if (this.scrollView) {
116
116
const safeAreatop = Utils . layout . toDeviceIndependentPixels ( this . getSafeAreaInsets ( ) . top ) ;
117
+ // if (global.isIOS) {
118
+ // // why do we get need :s
119
+ // safeAreatop -= 10;
120
+ // }
121
+ // const y = data.y - safeAreatop;
117
122
const y = data . y - safeAreatop ;
118
- // console.log(
119
- // 'shouldStartGesture ',
120
- // data.positions,
121
- // data.absoluteX,
122
- // data.y,
123
- // y,
124
- // this.viewHeight - (this.translationMaxOffset - this.translationY),
125
- // this.viewHeight,
126
- // this.translationMaxOffset,
127
- // this.translationY
128
- // );
123
+ // console.log('shouldStartGesture ', safeAreatop, data, y, this.viewHeight - (this.translationMaxOffset - this.translationY), this.translationY, this.translationMaxOffset, this.viewHeight);
129
124
if ( y < this . viewHeight - ( this . translationMaxOffset - this . translationY ) ) {
130
- // console.log('shouldStartGesture no go on background');
131
125
return false ;
132
126
}
133
127
if ( this . _scrollView ) {
134
128
const posY = this . _scrollView && this . scrollView . getLocationRelativeTo ( this ) . y - safeAreatop ;
135
129
if ( y >= posY && y <= posY + this . scrollView . getMeasuredHeight ( ) ) {
136
- // console.log('shouldStartGesture no go on scrollview', this.scrollView.isScrollEnabled);
137
130
return false ;
138
131
}
139
132
}
@@ -165,6 +158,7 @@ export class PersistentBottomSheet extends GridLayout {
165
158
return this . _translationY ;
166
159
}
167
160
set translationY ( value : number ) {
161
+ // console.log('set translationY', value)
168
162
if ( this . _translationY !== - 1 ) {
169
163
this . isScrollEnabled = value === 0 ;
170
164
}
@@ -174,7 +168,6 @@ export class PersistentBottomSheet extends GridLayout {
174
168
return this . steps [ this . steps . length - 1 ] ;
175
169
}
176
170
initNativeView ( ) {
177
- // this.iosOverflowSafeAreaEnabled = false;
178
171
super . initNativeView ( ) ;
179
172
if ( this . scrollView ) {
180
173
this . scrollView . on ( 'scroll' , this . onScroll , this ) ;
@@ -246,10 +239,11 @@ export class PersistentBottomSheet extends GridLayout {
246
239
this . scrollView . off ( 'touch' , this . onTouch , this ) ;
247
240
}
248
241
this . _scrollView = value ;
242
+
249
243
if ( value ) {
250
- if ( global . isIOS ) {
251
- ( value . nativeViewProtected as UIScrollView ) . delaysContentTouches = true ;
252
- }
244
+ // if (global.isIOS) {
245
+ // (value.nativeViewProtected as UIScrollView).delaysContentTouches = true;
246
+ // }
253
247
value . on ( 'scroll' , this . onScroll , this ) ;
254
248
value . on ( 'touch' , this . onTouch , this ) ;
255
249
}
@@ -277,8 +271,13 @@ export class PersistentBottomSheet extends GridLayout {
277
271
if ( newValue ) {
278
272
newValue . iosOverflowSafeAreaEnabled = false ;
279
273
newValue . verticalAlignment = 'bottom' ;
280
- const index = this . getChildrenCount ( ) ;
281
- this . addChild ( newValue ) ;
274
+ let index ;
275
+ if ( ! newValue . parent ) {
276
+ index = this . getChildrenCount ( ) ;
277
+ this . addChild ( newValue ) ;
278
+ } else {
279
+ index = this . getChildIndex ( newValue ) ;
280
+ }
282
281
if ( ! this . backDrop && this . backdropColor ) {
283
282
this . addBackdropView ( index ) ;
284
283
}
@@ -309,7 +308,6 @@ export class PersistentBottomSheet extends GridLayout {
309
308
const height = Math . round ( Utils . layout . toDeviceIndependentPixels ( contentView . getMeasuredHeight ( ) ) ) ;
310
309
this . viewHeight = height ;
311
310
if ( this . translationY === - 1 ) {
312
- // console.log('onLayoutChange', this.stepIndex);
313
311
const step = this . steps [ this . stepIndex ] ;
314
312
const ty = this . translationMaxOffset - step ;
315
313
this . translationY = ty ;
@@ -353,21 +351,25 @@ export class PersistentBottomSheet extends GridLayout {
353
351
} else {
354
352
touchY = ( event . ios . touches . anyObject ( ) as UITouch ) . locationInView ( null ) . y ;
355
353
}
356
- // console.log('onToucht', event.action, this.lastScrollY , touchY);
354
+ // console.log('onToucht', event.action, this.lastTouchY , touchY);
357
355
if ( event . action === 'down' ) {
358
- this . scrollViewTouched = true ;
359
- this . lastScrollY = this . scrollViewVerticalOffset ;
360
- this . scrollViewAtTop = this . lastScrollY === 0 ;
361
- if ( this . scrollViewAtTop ) {
362
- this . panGestureHandler . cancel ( ) ;
363
- }
356
+ // this.scrollViewTouched = true;
357
+ // this.lastScrollY = this.scrollViewVerticalOffset;
358
+ // this.scrollViewAtTop = this.lastScrollY === 0;
359
+ // if (this.scrollViewAtTop) {
360
+ // this.panGestureHandler.cancel();
361
+ // }
364
362
} else if ( event . action === 'up' || event . action === 'cancel' ) {
365
- this . scrollViewTouched = false ;
366
- if ( this . scrollViewAtTop ) {
367
- this . scrollViewAtTop = this . scrollView . verticalOffset === 0 ;
368
- const y = touchY - ( this . lastTouchY || touchY ) ;
369
- const totalDelta = this . translationY + y ;
370
- this . computeAndAnimateEndGestureAnimation ( totalDelta ) ;
363
+ if ( this . scrollViewTouched ) {
364
+ this . scrollViewTouched = false ;
365
+ if ( this . scrollViewAtTop ) {
366
+ this . scrollViewAtTop = this . scrollView . verticalOffset === 0 ;
367
+ const y = touchY - ( this . lastTouchY || touchY ) ;
368
+ if ( y !== 0 ) {
369
+ const totalDelta = this . translationY + y ;
370
+ this . computeAndAnimateEndGestureAnimation ( totalDelta ) ;
371
+ }
372
+ }
371
373
}
372
374
this . isScrollEnabled = true ;
373
375
} else if ( ( ! this . scrollViewTouched || this . scrollViewAtTop ) && event . action === 'move' ) {
@@ -472,6 +474,7 @@ export class PersistentBottomSheet extends GridLayout {
472
474
}
473
475
474
476
async animateToPosition ( position , duration = OPEN_DURATION ) {
477
+ // console.log('animateToPosition', position, new Error().stack);
475
478
if ( this . _scrollView && global . isAndroid ) {
476
479
// on android we get unwanted scroll effect while "swipping the view"
477
480
// cancel the views touches before animation to prevent that
0 commit comments