Event callbacks
The DotLottieAnimation
instance emits the following events that can be listened to via a class implementing the Observer
protocol:
class YourDotLottieObserver: Observer { func onComplete() { // do something }
func onFrame(frameNo: Float) { // do something }
func onLoad() { // do something }
func onLoadError() { // do something }
func onLoop(loopCount: UInt32) { // do something }
func onPause() { // do something }
func onPlay() { // do something }
func onRender(frameNo: Float) { // do something }
func onStop() { // do something }}
// In your view code
var animation = DotLottieAnimation(...)var animationView = DotLottieView(dotLottie: animation)var myObserver = YourDotLottieObserver()
animationView.subscribe(observer: myObserver)
Event | Description |
---|---|
onComplete | Emitted when the animation completes. |
onFrame(frameNo: Float) | Emitted when the animation reaches a new frame. |
onLoad | Emitted when the animation is loaded. |
onLoadError | Emitted when the animation failed to load. |
onLoop(loopCount: UIint32) | Emitted when the animation completes a loop. |
onPause | Emitted when the animation is paused. |
onPlay | Emitted when the animation starts playing. |
onRender(frameNo: Float) | Emitted when the frame is rendered. |
onStop | Emitted when the animation is stopped. |