DockProgress icon indicating copy to clipboard operation
DockProgress copied to clipboard

Make the progress animation smoother

Open sindresorhus opened this issue 7 years ago • 2 comments

Issuehunt badges

https://github.com/sindresorhus/DockProgress/blob/2fd7035c8c17e28b261efa04da91d3a6ad403cf2/Sources/DockProgress/DockProgress.swift#L40

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%.


IssueHunt Summary

Backers (Total: $100.00)

Submitted pull Requests


Become a backer now!

Or submit a pull request to get the deposits!

Tips


IssueHunt has been backed by the following sponsors. Become a sponsor

sindresorhus avatar Mar 01 '18 20:03 sindresorhus

@issuehuntfest has funded $100.00 to this issue. See it on IssueHunt

IssueHuntBot avatar Jan 09 '19 17:01 IssueHuntBot

@sindresorhus We could implement CADisplayLink. Basically 60fps animation. Shouldn't be too much code, and I need to update my own CADisplayLink animation libs anyways.

eonist avatar Apr 12 '19 07:04 eonist

I could take a look at this. However, I think performance issues with the badge/pie styles may want to be addressed first (some comments on performance: https://github.com/sindresorhus/DockProgress/pull/17)

hazeycode avatar May 17 '23 11:05 hazeycode

@sindresorhus has rewarded $90.00 to @hazeycode. See it on IssueHunt

  • :moneybag: Total deposit: $100.00
  • :tada: Repository reward(0%): $0.00
  • :wrench: Service fee(10%): $10.00

issuehunt-oss[bot] avatar May 24 '23 10:05 issuehunt-oss[bot]