Closed bukira closed 3 months ago
hey @bukira,
Actually there is but we had to make it faster. Here's why:
SwiftUI has a problem with resetting @State
values - it takes around ~0.3 seconds to reset the cache. So, in other words, if we use the same animation speed as for the entry, there may be a (very rare, but still) situation where you see the cached @State
value, from the previous popup "session". This can be fixed by the developer, by manually clearing the @State
value on popup disappear, but we wanted to avoid it, as this problem is really hard to detect.
Nevertheless, if you understand the problems related to this, you can fork the and change the code in one place:
File AnimationType
, line 24; just copy the value from line 17.
Thanks for your feedback and feel free to ask the further questions 😉
Thanks, what @Sate am I clearing? I am only showing 1 popup at a time
Let's say you have @State
value declared in your popup, like on the picture below:
This value is both displayed and changed by some element of the popup. If you would close the popup and then open in again within 1 second, you will see not an empty string (as you expect to), but the value from the previous session. For this reason, we made closing animation significantly faster.
ah ok, I have an init() on my popup where I inject the data to build the popup from so all @State inside the popup comes from the injected data
yeah, so you can play with the value a bit, but please keep this problem in your mind. Here's for example how it would work with this animation: .spring(response: 0.6, dampingFraction: 1, blendDuration: 0.1)
https://github.com/Mijick/PopupView/assets/23524947/a222d50f-5fc0-4d25-9e03-25f5164e2159
And if you or anyone else has an idea on how to fix this, please share it with us; because I too find it as a very difficult compromise 😉
There is no animation when dismissing a popup, which is a bit of shame as the animation on insert is great