Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

programmatic position change not animated #55

Closed
LinusGeffarth opened this issue Mar 4, 2022 · 2 comments
Closed

programmatic position change not animated #55

LinusGeffarth opened this issue Mar 4, 2022 · 2 comments

Comments

@LinusGeffarth
Copy link

When I programmatically change the position from middle/bottom to top, it works, but it's not animated. As animation option, I have set .spring(). I've made my own, custom BottomSheetPosition if that matters.

bottomSheetPosition is .middle by default. Then, in a button action, I set bottomSheetPosition = .top. This is how I initialize the bottom sheet:

.bottomSheet(bottomSheetPosition: $bottomSheetPosition, options: [
    .cornerRadius(15),
    .noBottomPosition,
    .animation(Animation.spring()),
    .shadow(color: Color(.sRGB, white: 0, opacity: 0.2), radius: 7, x: 0, y: 0)
    ]) {
    // ...
} mainContent: {
    // ...
}
@lucaszischka
Copy link
Owner

Have you tried using

withAnimation(.spring()) {
    self.bottomSheetPosition = .top
}

when setting the bottom sheet position programmatically?

@LinusGeffarth
Copy link
Author

that worked, thanks!

may still be an issue though because in the sample code it doesn't look like this extra animation wrapper shouldn't be needed...

Repository owner locked and limited conversation to collaborators Jun 26, 2022
@lucaszischka lucaszischka converted this issue into discussion #75 Jun 26, 2022

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants