@@ -58,6 +58,7 @@ import {
58
58
getKeyboardAnimationConfigs ,
59
59
normalizeSnapPoint ,
60
60
print ,
61
+ floatingPointEquals ,
61
62
} from '../../utilities' ;
62
63
import {
63
64
DEFAULT_OVER_DRAG_RESISTANCE_FACTOR ,
@@ -78,7 +79,7 @@ import {
78
79
DEFAULT_DYNAMIC_SIZING ,
79
80
DEFAULT_ACCESSIBLE ,
80
81
DEFAULT_ACCESSIBILITY_LABEL ,
81
- DEFAULT_ACCESSIBILITY_ROLE
82
+ DEFAULT_ACCESSIBILITY_ROLE ,
82
83
} from './constants' ;
83
84
import type { BottomSheetMethods , Insets } from '../../types' ;
84
85
import type { BottomSheetProps , AnimateToPositionType } from './types' ;
@@ -328,7 +329,7 @@ const BottomSheetComponent = forwardRef<BottomSheet, BottomSheetProps>(
328
329
// extended position = container height - sheet height
329
330
const extendedPosition =
330
331
animatedContainerHeight . value - animatedSheetHeight . value ;
331
- if ( animatedPosition . value === extendedPosition )
332
+ if ( floatingPointEquals ( animatedPosition . value , extendedPosition ) )
332
333
return SHEET_STATE . EXTENDED ;
333
334
334
335
// extended position with keyboard =
@@ -344,13 +345,16 @@ const BottomSheetComponent = forwardRef<BottomSheet, BottomSheetProps>(
344
345
if (
345
346
keyboardBehavior === KEYBOARD_BEHAVIOR . interactive &&
346
347
isInTemporaryPosition . value &&
347
- animatedPosition . value === extendedPositionWithKeyboard
348
+ floatingPointEquals (
349
+ animatedPosition . value ,
350
+ extendedPositionWithKeyboard
351
+ )
348
352
) {
349
353
return SHEET_STATE . EXTENDED ;
350
354
}
351
355
352
356
// fill parent = 0
353
- if ( animatedPosition . value === 0 ) {
357
+ if ( floatingPointEquals ( animatedPosition . value , 0 ) ) {
354
358
return SHEET_STATE . FILL_PARENT ;
355
359
}
356
360
@@ -633,7 +637,11 @@ const BottomSheetComponent = forwardRef<BottomSheet, BottomSheetProps>(
633
637
[ _providedOnChange , animatedCurrentIndex ]
634
638
) ;
635
639
const handleOnAnimate = useCallback (
636
- function handleOnAnimate ( toPoint : number , source : ANIMATION_SOURCE , snapPoints : number [ ] ) {
640
+ function handleOnAnimate (
641
+ toPoint : number ,
642
+ source : ANIMATION_SOURCE ,
643
+ snapPoints : number [ ]
644
+ ) {
637
645
const closedPosition = animatedClosedPosition . value ;
638
646
const toIndex =
639
647
toPoint === closedPosition ? - 1 : snapPoints . indexOf ( toPoint ) ;
@@ -700,10 +708,10 @@ const BottomSheetComponent = forwardRef<BottomSheet, BottomSheetProps>(
700
708
configs ?: WithTimingConfig | WithSpringConfig
701
709
) {
702
710
if (
703
- position === animatedPosition . value ||
711
+ floatingPointEquals ( position , animatedPosition . value ) ||
704
712
position === undefined ||
705
713
( animatedAnimationState . value === ANIMATION_STATE . RUNNING &&
706
- position === animatedNextPosition . value )
714
+ floatingPointEquals ( position , animatedNextPosition . value ) )
707
715
) {
708
716
return ;
709
717
}
0 commit comments