mutualmobile / MMProgressHUD

An easy-to-use HUD interface with personality.
MIT License
705 stars 131 forks source link

A couple adjustments to prevent flickering on Drop style ... #5

Closed Air-Craft closed 10 years ago

Air-Craft commented 11 years ago

...when dismiss is called too soon.

There are two issues that occur when dismiss is called before show is complete. The first is the setting of the hud's position and transform immediately on calling dismiss which causes it to disappear for a moment until the dismiss animation kicks in.

The second is the completion block for the background fade which cleans up and hides the UIWindow containing the HUD causing it to disappear before it's off screen. I've put in a delay if progress < 0. It's a touch hack-ish but it's quite a sophisticated system and I'm hoping you might have a better solution :)

Love the drop-style by the way - perfect for my client project! I'll let you know the app when it's out of NDA :)

larsacus commented 11 years ago

Is this only happening with the "drop" animation?

Air-Craft commented 10 years ago

Hi, just had another go at fixing this. the issues come when the dismiss action is queued (fired before the show completes). Logically, you don't want to fire the UIView animation to hide the gradient and window before the beginning of the dismiss action. There is no showActionCompletion property so I hooked the UIView animation into the dismissActionCompletion block which seems fine visual as it's quite quick anyway. This seems to work... Great lib by the way...good code :)

larsacus commented 10 years ago

I like your second approach much better :smiley:

Air-Craft commented 10 years ago

Hi, see that last commit. I've changed the self back to blockSelf, but the technique is kosher I believe. I learned it from digging around the @weakify / @strongify macros in ReactiveCocoa. Worth a look!

larsacus commented 10 years ago

Yeah it's the same principle as the weakify/strongify macros, just simpler. Not reusing self is just a semantic issue here.