Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bottom sheet state - progress does not expose correct value #53

Open
MFlisar opened this issue Jan 15, 2025 · 5 comments
Open

bottom sheet state - progress does not expose correct value #53

MFlisar opened this issue Jan 15, 2025 · 5 comments
Labels
bug Something isn't working

Comments

@MFlisar
Copy link

MFlisar commented Jan 15, 2025

When observing the bottom sheet state I see that the progress jumps to 1 as soon as I drag the bottom sheet to 50% and then it stays there.

LaunchedEffect(sheetState.targetDetent, sheetState.progress, sheetState.offset) {
     println("sheetState.progress = ${sheetState.progress}  | sheetState.offset = ${sheetState.offset} | sheetState.targetDetent = ${sheetState.targetDetent.identifier}")
 }

Logs look like following then:

// ... 
sheetState.progress = 0.5208952  | sheetState.offset = 1149.8516 | sheetState.targetDetent = hidden
sheetState.progress = 0.5164543  | sheetState.offset = 1160.5098 | sheetState.targetDetent = hidden
sheetState.progress = 0.5123608  | sheetState.offset = 1170.334 | sheetState.targetDetent = hidden
sheetState.progress = 0.5083179  | sheetState.offset = 1180.0371 | sheetState.targetDetent = hidden
sheetState.progress = 0.5039864  | sheetState.offset = 1190.4326 | sheetState.targetDetent = hidden
sheetState.progress = 0.50002766  | sheetState.offset = 1199.9336 | sheetState.targetDetent = hidden
sheetState.progress = 1.0  | sheetState.offset = 1208.8184 | sheetState.targetDetent = fully-expanded
sheetState.progress = 1.0  | sheetState.offset = 1217.7559 | sheetState.targetDetent = fully-expanded
sheetState.progress = 1.0  | sheetState.offset = 1225.1719 | sheetState.targetDetent = fully-expanded
sheetState.progress = 1.0  | sheetState.offset = 1232.7891 | sheetState.targetDetent = fully-expanded
// ... 

Seems like the internal logic skips the next best value (the closest inside UnstyledDraggableAnchors) and as a side effect the progress between settled and target instantly becomes 1...

Notes

  • I use version 1.20.0
  • I use a bottom sheet with extended and hidden state only
@feresr
Copy link

feresr commented Jan 21, 2025

+1 I'm facing the same issue!

@alexstyl
Copy link
Member

Thanks for reporting this issue @MFlisar. I am planning of having a look at all the issues around the end of this week.

Could you both kindly let me know if this is a blocker for you or how it affects you?

@alexstyl alexstyl added the bug Something isn't working label Jan 22, 2025
@feresr
Copy link

feresr commented Jan 22, 2025

Hey @alexstyl thanks for the follow-up, it's not a blocker in my case, just a UI tweak.
I'm trying to hook up the Scrim alpha to this value so that it appears/disappears as the user pulls the sheet down.

@MFlisar
Copy link
Author

MFlisar commented Jan 22, 2025

I'm doing something similar - I want to animate something in parallel to the bottom sheet. No big deal though as long as sheetState.offset is working, I can always calculate the progress myself...

@hannta
Copy link

hannta commented Jan 30, 2025

I'm also facing this issue when trying to animate content based on the bottom sheet's position.

As others have mentioned, the workaround is to use sheetState.offset. Though the documentation states that offset ranges from 0 to 1, it actually is the sheet's height. Because of this, sheetState.isIdle does not work as expected, it checks whether offset is exactly 1 or 0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants