Make the progress animation smoother #1
sindresorhus posted onGitHub
Right now it only updates each time progressValue
is updated or the NSProgress instance in progress
changes. Let say you use this to update on each processed frame of a video, so the longer the video is, the smoother the progress animation is. That also means it will be pretty choppy on short clips.
Normally you would use a CALayer, which would animate 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.
I think we should also fade-in and fade-out the progress animation so it doesn't just suddenly appear at 0% and disappear at 100%.