Improve text spoiler animations

This commit is contained in:
Isaac
2024-05-31 11:50:48 +04:00
parent 9ea80ff9dc
commit 0e668a5fa2
6 changed files with 392 additions and 146 deletions

View File

@@ -553,18 +553,18 @@ public extension ContainedViewLayoutTransition {
}
}
func animateFrame(layer: CALayer, from frame: CGRect, to toFrame: CGRect? = nil, removeOnCompletion: Bool = true, additive: Bool = false, completion: ((Bool) -> Void)? = nil) {
func animateFrame(layer: CALayer, from frame: CGRect, to toFrame: CGRect? = nil, delay: Double = 0.0, removeOnCompletion: Bool = true, additive: Bool = false, completion: ((Bool) -> Void)? = nil) {
switch self {
case .immediate:
case .immediate:
if let completion = completion {
completion(true)
}
case let .animated(duration, curve):
layer.animateFrame(from: frame, to: toFrame ?? layer.frame, duration: duration, delay: delay, timingFunction: curve.timingFunction, mediaTimingFunction: curve.mediaTimingFunction, removeOnCompletion: removeOnCompletion, additive: additive, completion: { result in
if let completion = completion {
completion(true)
completion(result)
}
case let .animated(duration, curve):
layer.animateFrame(from: frame, to: toFrame ?? layer.frame, duration: duration, timingFunction: curve.timingFunction, mediaTimingFunction: curve.mediaTimingFunction, removeOnCompletion: removeOnCompletion, additive: additive, completion: { result in
if let completion = completion {
completion(result)
}
})
})
}
}