@@ -58,6 +58,7 @@ import {
5858 getKeyboardAnimationConfigs ,
5959 normalizeSnapPoint ,
6060 print ,
61+ floatingPointEquals ,
6162} from '../../utilities' ;
6263import {
6364 DEFAULT_OVER_DRAG_RESISTANCE_FACTOR ,
@@ -78,7 +79,7 @@ import {
7879 DEFAULT_DYNAMIC_SIZING ,
7980 DEFAULT_ACCESSIBLE ,
8081 DEFAULT_ACCESSIBILITY_LABEL ,
81- DEFAULT_ACCESSIBILITY_ROLE
82+ DEFAULT_ACCESSIBILITY_ROLE ,
8283} from './constants' ;
8384import type { BottomSheetMethods , Insets } from '../../types' ;
8485import type { BottomSheetProps , AnimateToPositionType } from './types' ;
@@ -328,7 +329,7 @@ const BottomSheetComponent = forwardRef<BottomSheet, BottomSheetProps>(
328329 // extended position = container height - sheet height
329330 const extendedPosition =
330331 animatedContainerHeight . value - animatedSheetHeight . value ;
331- if ( animatedPosition . value === extendedPosition )
332+ if ( floatingPointEquals ( animatedPosition . value , extendedPosition ) )
332333 return SHEET_STATE . EXTENDED ;
333334
334335 // extended position with keyboard =
@@ -344,13 +345,16 @@ const BottomSheetComponent = forwardRef<BottomSheet, BottomSheetProps>(
344345 if (
345346 keyboardBehavior === KEYBOARD_BEHAVIOR . interactive &&
346347 isInTemporaryPosition . value &&
347- animatedPosition . value === extendedPositionWithKeyboard
348+ floatingPointEquals (
349+ animatedPosition . value ,
350+ extendedPositionWithKeyboard
351+ )
348352 ) {
349353 return SHEET_STATE . EXTENDED ;
350354 }
351355
352356 // fill parent = 0
353- if ( animatedPosition . value === 0 ) {
357+ if ( floatingPointEquals ( animatedPosition . value , 0 ) ) {
354358 return SHEET_STATE . FILL_PARENT ;
355359 }
356360
@@ -633,7 +637,11 @@ const BottomSheetComponent = forwardRef<BottomSheet, BottomSheetProps>(
633637 [ _providedOnChange , animatedCurrentIndex ]
634638 ) ;
635639 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+ ) {
637645 const closedPosition = animatedClosedPosition . value ;
638646 const toIndex =
639647 toPoint === closedPosition ? - 1 : snapPoints . indexOf ( toPoint ) ;
@@ -700,10 +708,10 @@ const BottomSheetComponent = forwardRef<BottomSheet, BottomSheetProps>(
700708 configs ?: WithTimingConfig | WithSpringConfig
701709 ) {
702710 if (
703- position === animatedPosition . value ||
711+ floatingPointEquals ( position , animatedPosition . value ) ||
704712 position === undefined ||
705713 ( animatedAnimationState . value === ANIMATION_STATE . RUNNING &&
706- position === animatedNextPosition . value )
714+ floatingPointEquals ( position , animatedNextPosition . value ) )
707715 ) {
708716 return ;
709717 }
0 commit comments