Gifski
Gifski copied to clipboard
Improve Dock icon progress animation
https://github.com/sindresorhus/gifski-app/blob/9ea67499164b40ae76a872bf5087eb7ba29cda5d/Gifski/AppDelegate.swift#L43
Right now it only updates once per video frame we process. So the longer the video is, the smoother the progress animation is. That also means it will be pretty choppy on short clips. The main window progress circle uses CALayer which animates between the progress events. This is however not possible for the Dock icon as we have to call .display() manually each time we want to update it. I tried to use CALayer and just capture an image of the layer 30 times a second, but it seems it's only possible to capture before or after the animation.
I think the solution is to simply implement the animation ourselves with an interval timer. We already have the previous progress and the current progress, so we can animate between them. It's a bit more complicated though as if we receive a new progress change while we're animation, we now need to animate to the new progress.
I'm also happy to consider other ideas.
@sindresorhus This looks interesting! Ill poke at it this weekend
@wuweiweiwu Great!
FYI, I moved the code into a separate package, so this issue is now continued at: https://github.com/sindresorhus/DockProgress/issues/1
I'm keeping this issue open, but locked, for discovery.