mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-23 22:55:00 +00:00
Dice fixes
This commit is contained in:
@@ -10,7 +10,6 @@ import SwiftSignalKit
|
||||
|
||||
public final class ManagedAnimationState {
|
||||
public let item: ManagedAnimationItem
|
||||
|
||||
private let instance: LottieInstance
|
||||
|
||||
let frameCount: Int
|
||||
@@ -19,6 +18,8 @@ public final class ManagedAnimationState {
|
||||
var relativeTime: Double = 0.0
|
||||
public var frameIndex: Int?
|
||||
|
||||
public var executedCallbacks = Set<Int>()
|
||||
|
||||
private let renderContext: DrawingContext
|
||||
|
||||
public init?(displaySize: CGSize, item: ManagedAnimationItem, current: ManagedAnimationState?) {
|
||||
@@ -109,17 +110,19 @@ public enum ManagedAnimationSource: Equatable {
|
||||
}
|
||||
}
|
||||
|
||||
public struct ManagedAnimationItem: Equatable {
|
||||
public struct ManagedAnimationItem {
|
||||
public let source: ManagedAnimationSource
|
||||
var frames: ManagedAnimationFrameRange?
|
||||
var duration: Double?
|
||||
var loop: Bool
|
||||
var callbacks: [(Int, () -> Void)]
|
||||
|
||||
public init(source: ManagedAnimationSource, frames: ManagedAnimationFrameRange? = nil, duration: Double? = nil, loop: Bool = false) {
|
||||
public init(source: ManagedAnimationSource, frames: ManagedAnimationFrameRange? = nil, duration: Double? = nil, loop: Bool = false, callbacks: [(Int, () -> Void)] = []) {
|
||||
self.source = source
|
||||
self.frames = frames
|
||||
self.duration = duration
|
||||
self.loop = loop
|
||||
self.callbacks = callbacks
|
||||
}
|
||||
}
|
||||
|
||||
@@ -240,6 +243,13 @@ open class ManagedAnimationNode: ASDisplayNode {
|
||||
if let image = state.draw() {
|
||||
self.imageNode.image = image
|
||||
}
|
||||
|
||||
for (callbackFrame, callback) in state.item.callbacks {
|
||||
if !state.executedCallbacks.contains(callbackFrame) && frameIndex >= callbackFrame {
|
||||
state.executedCallbacks.insert(callbackFrame)
|
||||
callback()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var animationAdvancement: Double = 1.0 / 60.0
|
||||
|
||||
Reference in New Issue
Block a user