LottieUI
LottieUI copied to clipboard
Add support for observers for macOS
Currently, the Mac version of LottieView do not support observation of the current progress/frame rate of an animation. For the iOS counterpart, I'm using CADisplayLink
to observe the animation, but unfortunately it's not available on AppKit.
If anyone has any suggestion on how I could keep track of the animation's progress on macOS, feel free to let me know! You're also welcome to contribute with a pull request with your implementation if you're feeling extra generous.
Thanks for your help!
https://stackoverflow.com/questions/14158743/alternative-of-cadisplaylink-for-mac-os-x
Thanks for the suggestions @Psli! I'll give them a read later and see if I can work something out. Meanwhile, if you managed to get something working on your end with these, feel free to contribute with a pull request if you're feeling generous!
I've got something working with CVDisplayLink, it's currently on the dev
branch:
https://github.com/tfmart/LottieUI/blob/55d7ce4e2258484063d3d7cc2af2a926353537e8/Sources/LottieUI/macOS/AnimationProgressObserver%2BmacOS.swift
However, it seems that both this new solution for macOS and the current one for iOS with CADisplayLink doesn't seem to work with the new Core Animation engine introduced in Lottie 4.0. I'll attempt to take a second look at this issue at a later time, it might also be interesting to open a discussion or issue at Lottie's repo as well regarding this.
If you must use either the .onProgress
or onFrame
modifiers, it's required to use the main thread rendering engine, which can be done with the .renderingEngine
modifier:
LottieView("MyAnimation")
.renderingEngine(.mainThread)
.onProgress { _ in
// ...
}
I've just released v1.3.3 which includes the framerate/progress observers for macOS! However, there's an issue when using Lottie's new Core Animation rendering engine, for both iOS and macOS.
I'll be closing this issue since the observers are now available, and for further discussion about the rendering engine issues, I've opened issue #10 to do so