mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-22 22:25:57 +00:00
Filter repeated animations
This commit is contained in:
@@ -1669,7 +1669,7 @@ public final class ControlledTransition {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for i in removeAnimationIndices.reversed() {
|
for i in Set(removeAnimationIndices).sorted().reversed() {
|
||||||
self.animations.remove(at: i).complete(atEnd: false)
|
self.animations.remove(at: i).complete(atEnd: false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1701,8 +1701,19 @@ public final class ControlledTransition {
|
|||||||
self.animations.removeAll()
|
self.animations.removeAll()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private func add(animation: ControlledTransitionProperty) {
|
||||||
|
for i in 0 ..< self.animations.count {
|
||||||
|
let otherAnimation = self.animations[i]
|
||||||
|
if otherAnimation.layer === animation.layer && otherAnimation.keyPath == animation.keyPath {
|
||||||
|
self.animations.remove(at: i)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
self.animations.append(animation)
|
||||||
|
}
|
||||||
|
|
||||||
public func updateAlpha(layer: CALayer, alpha: CGFloat, completion: ((Bool) -> Void)?) {
|
public func updateAlpha(layer: CALayer, alpha: CGFloat, completion: ((Bool) -> Void)?) {
|
||||||
self.animations.append(ControlledTransitionProperty(
|
self.add(animation: ControlledTransitionProperty(
|
||||||
layer: layer,
|
layer: layer,
|
||||||
keyPath: \.opacity,
|
keyPath: \.opacity,
|
||||||
fromValue: layer.opacity,
|
fromValue: layer.opacity,
|
||||||
@@ -1712,7 +1723,7 @@ public final class ControlledTransition {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public func updatePosition(layer: CALayer, position: CGPoint, completion: ((Bool) -> Void)?) {
|
public func updatePosition(layer: CALayer, position: CGPoint, completion: ((Bool) -> Void)?) {
|
||||||
self.animations.append(ControlledTransitionProperty(
|
self.add(animation: ControlledTransitionProperty(
|
||||||
layer: layer,
|
layer: layer,
|
||||||
keyPath: \.position,
|
keyPath: \.position,
|
||||||
fromValue: layer.position,
|
fromValue: layer.position,
|
||||||
@@ -1722,7 +1733,7 @@ public final class ControlledTransition {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public func updateBounds(layer: CALayer, bounds: CGRect, completion: ((Bool) -> Void)?) {
|
public func updateBounds(layer: CALayer, bounds: CGRect, completion: ((Bool) -> Void)?) {
|
||||||
self.animations.append(ControlledTransitionProperty(
|
self.add(animation: ControlledTransitionProperty(
|
||||||
layer: layer,
|
layer: layer,
|
||||||
keyPath: \.bounds,
|
keyPath: \.bounds,
|
||||||
fromValue: layer.bounds,
|
fromValue: layer.bounds,
|
||||||
@@ -1732,7 +1743,7 @@ public final class ControlledTransition {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public func updateFrame(layer: CALayer, frame: CGRect, completion: ((Bool) -> Void)?) {
|
public func updateFrame(layer: CALayer, frame: CGRect, completion: ((Bool) -> Void)?) {
|
||||||
self.animations.append(ControlledTransitionProperty(
|
self.add(animation: ControlledTransitionProperty(
|
||||||
layer: layer,
|
layer: layer,
|
||||||
keyPath: \.frame,
|
keyPath: \.frame,
|
||||||
fromValue: layer.frame,
|
fromValue: layer.frame,
|
||||||
|
|||||||
Reference in New Issue
Block a user