mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-08-08 08:31:13 +00:00
Animation menu improvements
This commit is contained in:
parent
c7c46e23b0
commit
56115402e1
@ -13,6 +13,7 @@ swift_library(
|
|||||||
"//submodules/Display:Display",
|
"//submodules/Display:Display",
|
||||||
"//submodules/AsyncDisplayKit:AsyncDisplayKit",
|
"//submodules/AsyncDisplayKit:AsyncDisplayKit",
|
||||||
"//submodules/LegacyComponents:LegacyComponents",
|
"//submodules/LegacyComponents:LegacyComponents",
|
||||||
|
"//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit",
|
||||||
],
|
],
|
||||||
visibility = [
|
visibility = [
|
||||||
"//visibility:public",
|
"//visibility:public",
|
||||||
|
@ -3,6 +3,7 @@ import UIKit
|
|||||||
import Display
|
import Display
|
||||||
import AsyncDisplayKit
|
import AsyncDisplayKit
|
||||||
import LegacyComponents
|
import LegacyComponents
|
||||||
|
import SwiftSignalKit
|
||||||
|
|
||||||
private final class RadialProgressContentCancelNodeParameters: NSObject {
|
private final class RadialProgressContentCancelNodeParameters: NSObject {
|
||||||
let color: UIColor
|
let color: UIColor
|
||||||
@ -159,23 +160,28 @@ private final class RadialProgressContentSpinnerNode: ASDisplayNode {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private var hierarchyVersion: Int = 0
|
||||||
override func willEnterHierarchy() {
|
override func willEnterHierarchy() {
|
||||||
super.willEnterHierarchy()
|
super.willEnterHierarchy()
|
||||||
|
|
||||||
if self.animateRotation {
|
if self.animateRotation {
|
||||||
let basicAnimation = CABasicAnimation(keyPath: "transform.rotation.z")
|
self.hierarchyVersion += 1
|
||||||
basicAnimation.duration = 1.5
|
|
||||||
var fromValue = Float.pi + 0.58
|
|
||||||
if let presentation = self.layer.presentation(), let value = (presentation.value(forKeyPath: "transform.rotation.z") as? NSNumber)?.floatValue {
|
|
||||||
fromValue = value
|
|
||||||
}
|
|
||||||
basicAnimation.fromValue = NSNumber(value: fromValue)
|
|
||||||
basicAnimation.toValue = NSNumber(value: fromValue + Float.pi * 2.0)
|
|
||||||
basicAnimation.repeatCount = Float.infinity
|
|
||||||
basicAnimation.timingFunction = CAMediaTimingFunction(name: CAMediaTimingFunctionName.linear)
|
|
||||||
basicAnimation.beginTime = 0.0
|
|
||||||
|
|
||||||
self.layer.add(basicAnimation, forKey: "progressRotation")
|
if self.layer.animation(forKey: "progressRotation") == nil {
|
||||||
|
let basicAnimation = CABasicAnimation(keyPath: "transform.rotation.z")
|
||||||
|
basicAnimation.duration = 1.5
|
||||||
|
var fromValue = Float.pi + 0.58
|
||||||
|
if let presentation = self.layer.presentation(), let value = (presentation.value(forKeyPath: "transform.rotation.z") as? NSNumber)?.floatValue {
|
||||||
|
fromValue = value
|
||||||
|
}
|
||||||
|
basicAnimation.fromValue = NSNumber(value: fromValue)
|
||||||
|
basicAnimation.toValue = NSNumber(value: fromValue + Float.pi * 2.0)
|
||||||
|
basicAnimation.repeatCount = Float.infinity
|
||||||
|
basicAnimation.timingFunction = CAMediaTimingFunction(name: CAMediaTimingFunctionName.linear)
|
||||||
|
basicAnimation.beginTime = 0.0
|
||||||
|
|
||||||
|
self.layer.add(basicAnimation, forKey: "progressRotation")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -183,7 +189,12 @@ private final class RadialProgressContentSpinnerNode: ASDisplayNode {
|
|||||||
super.didExitHierarchy()
|
super.didExitHierarchy()
|
||||||
|
|
||||||
if self.animateRotation {
|
if self.animateRotation {
|
||||||
self.layer.removeAnimation(forKey: "progressRotation")
|
let version = self.hierarchyVersion
|
||||||
|
Queue.mainQueue().after(0.1, {
|
||||||
|
if self.hierarchyVersion == version {
|
||||||
|
self.layer.removeAnimation(forKey: "progressRotation")
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user