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

Use animation(_:value:) #59

Closed
Rheaparks opened this issue Mar 21, 2022 · 2 comments
Closed

Use animation(_:value:) #59

Rheaparks opened this issue Mar 21, 2022 · 2 comments
Labels
Thank You ❤️ For people who appreciate my work

Comments

@Rheaparks
Copy link

Hello again,

I've got another issue… 😅
I'm using BottomSheet on a View containing an embedded MapBox map and I got a crash while initially loading the view. It occurs about half the time and when it doesn't crash, the map is animating weirdly. Like, it expands from the top-left corner to the bottom-right corner in a slow manner.

Upon further investigation, I noticed this only happened if I used BottomSheet. Having recently read that the standard animation() function is now deprecated. I theorised that maybe it's the use of animations by the library that could be the culprit. Since BottomSheet is used with a View Modifier, potential animations in the sheet could impact the rest of the app.

I made a fork of the library to see if I could fix my bug. And I did! I just had to remove a few withAnimation() calls. Now I don't have my crash anymore and apparently the BottomSheet is still behaving and animating ok. See the commit here.

I think the correct solution would be to use the now recommended way of doing animations. I mean animation(_:value:). Doing this would ensure that the animations are restricted to only the relevant state changes.

I don't know a lot about all of this, having seldom used animations in SwiftUI myself. Anyway, I'm sorry for reporting a lot of issues, and I thank you for maintaining this project. 🙂

@lucaszischka
Copy link
Owner

Yes this is indeed something I want to change in a future release. But only for code style purposes and not for functionality. I’m already removed all implicit animations (see #31) and I’m not sure how the withAnimation { } clousure crashes your app, when .animation(value) doesn't.

the map is animating weirdly. Like, it expands from the top-left corner to the bottom-right corner in a slow manner.

Have you tried using .fixedSize() on your map? Does this fix it?

@lucaszischka lucaszischka added the Thank You ❤️ For people who appreciate my work label Mar 21, 2022
@Rheaparks
Copy link
Author

Thank you for your very helpful answers! You helped me a lot on my other reported issues. I'm sorry, I really thought I'd found a problem and that I was helping. 🙏

I hadn't tried using .fixedSize(), but I just did and it breaks my component. For now, I'll stick with my quick fix… But this issue is the most complex I think. It could also come from MapBox, or from the way I'm embedding it in SwiftUI. I'll keep you posted if I find anything relevant to BottomSheet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Thank You ❤️ For people who appreciate my work
Projects
None yet
Development

No branches or pull requests

2 participants