@@ -345,10 +345,19 @@ export default class BottomSheetBehavior extends React.Component<Props, State> {
345
345
this . state = BottomSheetBehavior . getDerivedStateFromProps ( props , undefined )
346
346
347
347
const { snapPoints, init } = this . state
348
- const middlesOfSnapPoints : Animated . Node < number > [ ] = [ ]
348
+ const middlesOfSnapPoints : [
349
+ Animated . Node < number > ,
350
+ Animated . Node < number >
351
+ ] [ ] = [ ]
352
+
349
353
for ( let i = 1 ; i < snapPoints . length ; i ++ ) {
350
- middlesOfSnapPoints . push ( divide ( add ( snapPoints [ i - 1 ] , snapPoints [ i ] ) , 2 ) )
354
+ const tuple : [ Animated . Node < number > , Animated . Node < number > ] = [
355
+ add ( snapPoints [ i - 1 ] , 10 ) ,
356
+ sub ( snapPoints [ i ] , 25 ) ,
357
+ ]
358
+ middlesOfSnapPoints . push ( tuple )
351
359
}
360
+
352
361
const masterOffseted = new Value ( init )
353
362
// destination point is a approximation of movement if finger released
354
363
const tossForMaster =
@@ -360,14 +369,35 @@ export default class BottomSheetBehavior extends React.Component<Props, State> {
360
369
masterOffseted ,
361
370
multiply ( tossForMaster , this . masterVelocity )
362
371
)
372
+
373
+ const positive = greaterOrEq (
374
+ multiply ( tossForMaster , this . masterVelocity ) ,
375
+ 0
376
+ )
363
377
// method for generating condition for finding the nearest snap point
364
378
const currentSnapPoint = ( i = 0 ) : Animated . Node < number > =>
365
379
i + 1 === snapPoints . length
366
380
? snapPoints [ i ]
367
381
: cond (
368
- lessThan ( destinationPoint , middlesOfSnapPoints [ i ] ) ,
369
- snapPoints [ i ] ,
370
- currentSnapPoint ( i + 1 )
382
+ positive ,
383
+ cond (
384
+ greaterThan ( destinationPoint , middlesOfSnapPoints [ i ] [ 0 ] ) ,
385
+ cond (
386
+ lessThan ( destinationPoint , middlesOfSnapPoints [ i ] [ 1 ] ) ,
387
+ snapPoints [ i + 1 ] ,
388
+ currentSnapPoint ( i + 1 )
389
+ ) ,
390
+ snapPoints [ i ]
391
+ ) ,
392
+ cond (
393
+ greaterThan ( destinationPoint , middlesOfSnapPoints [ i ] [ 1 ] ) ,
394
+ cond (
395
+ lessThan ( destinationPoint , middlesOfSnapPoints [ i ] [ 0 ] ) ,
396
+ snapPoints [ i + 1 ] ,
397
+ currentSnapPoint ( i + 1 )
398
+ ) ,
399
+ snapPoints [ i ]
400
+ )
371
401
)
372
402
// current snap point desired
373
403
this . snapPoint = currentSnapPoint ( )
0 commit comments