@@ -16,11 +16,13 @@ import { interpret } from 'xstate'
16
16
export interface BottomSheetMachineProps {
17
17
initialHeight ?: number | GetInitialHeight
18
18
snapPoints ?: GetSnapPoints
19
+ unstable__requestAnimationFrame ?: boolean
19
20
}
20
21
21
22
function createStore ( {
22
23
initialHeight = defaultInitialHeight ,
23
24
snapPoints = defaultSnapPoints ,
25
+ unstable__requestAnimationFrame = false ,
24
26
} : BottomSheetMachineProps = { } ) {
25
27
console . debug ( 'createStore' )
26
28
const service = interpret (
@@ -51,15 +53,16 @@ function createStore({
51
53
transient = state
52
54
console . log ( 'transient' , state . value , state . context )
53
55
if ( state . changed ) {
54
- cancelAnimationFrame ( rAF )
55
- rAF = requestAnimationFrame ( ( ) => {
56
- console . group ( 'onStoreChange' )
57
- console . log ( { value : state . value , context : state . context } )
58
- transient = snapshot = state
59
- onStoreChange ( )
60
- console . groupEnd ( )
61
- } )
62
- console . groupEnd ( )
56
+ if ( unstable__requestAnimationFrame ) {
57
+ cancelAnimationFrame ( rAF )
58
+ rAF = requestAnimationFrame ( ( ) => {
59
+ console . group ( 'onStoreChange' )
60
+ console . log ( { value : state . value , context : state . context } )
61
+ transient = snapshot = state
62
+ onStoreChange ( )
63
+ console . groupEnd ( )
64
+ } )
65
+ } else onStoreChange ( )
63
66
}
64
67
console . groupEnd ( )
65
68
} )
0 commit comments