mirror of
https://github.com/TelegramMessenger/Telegram-iOS.git
synced 2026-07-06 03:33:41 +02:00
Various improvements
This commit is contained in:
parent
9dd6d95be6
commit
87630b6e74
7 changed files with 22 additions and 24 deletions
|
|
@ -132,7 +132,7 @@ public extension CALayer {
|
|||
|
||||
return animation
|
||||
} else if duration == 0.5 {
|
||||
let animation = makeSpringAnimation(keyPath)
|
||||
let animation = makeSpringAnimation(keyPath, duration: duration)
|
||||
animation.fromValue = from
|
||||
animation.toValue = to
|
||||
animation.isRemovedOnCompletion = removeOnCompletion
|
||||
|
|
@ -297,12 +297,7 @@ public extension CALayer {
|
|||
}
|
||||
|
||||
func springAnimation(from: AnyObject, to: AnyObject, keyPath: String, duration: Double, delay: Double = 0.0, initialVelocity: CGFloat = 0.0, damping: CGFloat = 88.0, removeOnCompletion: Bool = true, additive: Bool = false) -> CABasicAnimation {
|
||||
let animation: CABasicAnimation
|
||||
if #available(iOS 9.0, *) {
|
||||
animation = makeSpringBounceAnimation(keyPath, initialVelocity, damping)
|
||||
} else {
|
||||
animation = makeSpringAnimation(keyPath)
|
||||
}
|
||||
let animation = makeSpringBounceAnimation(keyPath, initialVelocity, damping)
|
||||
animation.fromValue = from
|
||||
animation.toValue = to
|
||||
animation.isRemovedOnCompletion = removeOnCompletion
|
||||
|
|
@ -328,12 +323,7 @@ public extension CALayer {
|
|||
}
|
||||
|
||||
func animateSpring(from: AnyObject, to: AnyObject, keyPath: String, duration: Double, delay: Double = 0.0, initialVelocity: CGFloat = 0.0, damping: CGFloat = 88.0, removeOnCompletion: Bool = true, additive: Bool = false, completion: ((Bool) -> Void)? = nil) {
|
||||
let animation: CABasicAnimation
|
||||
if #available(iOS 9.0, *) {
|
||||
animation = makeSpringBounceAnimation(keyPath, initialVelocity, damping)
|
||||
} else {
|
||||
animation = makeSpringAnimation(keyPath)
|
||||
}
|
||||
let animation = makeSpringBounceAnimation(keyPath, initialVelocity, damping)
|
||||
animation.fromValue = from
|
||||
animation.toValue = to
|
||||
animation.isRemovedOnCompletion = removeOnCompletion
|
||||
|
|
|
|||
|
|
@ -3246,7 +3246,7 @@ open class ListView: ASDisplayNode, ASScrollViewDelegate, ASGestureRecognizerDel
|
|||
case let .Spring(duration):
|
||||
headerNodesTransition = (.animated(duration: duration, curve: .spring), false, -completeOffset)
|
||||
animationCurve = .spring
|
||||
let springAnimation = makeSpringAnimation("sublayerTransform")
|
||||
let springAnimation = makeSpringAnimation("sublayerTransform", duration: duration)
|
||||
springAnimation.fromValue = NSValue(caTransform3D: CATransform3DMakeTranslation(0.0, -completeOffset, 0.0))
|
||||
springAnimation.toValue = NSValue(caTransform3D: CATransform3DIdentity)
|
||||
springAnimation.isRemovedOnCompletion = true
|
||||
|
|
@ -3327,7 +3327,7 @@ open class ListView: ASDisplayNode, ASScrollViewDelegate, ASGestureRecognizerDel
|
|||
})
|
||||
}
|
||||
|
||||
let springAnimation = makeSpringAnimation("sublayerTransform")
|
||||
let springAnimation = makeSpringAnimation("sublayerTransform", duration: duration)
|
||||
springAnimation.fromValue = NSValue(caTransform3D: CATransform3DMakeTranslation(0.0, -completeOffset, 0.0))
|
||||
springAnimation.toValue = NSValue(caTransform3D: CATransform3DIdentity)
|
||||
springAnimation.isRemovedOnCompletion = true
|
||||
|
|
@ -3576,7 +3576,7 @@ open class ListView: ASDisplayNode, ASScrollViewDelegate, ASGestureRecognizerDel
|
|||
case let .Spring(duration):
|
||||
animationCurve = .spring
|
||||
animationDuration = duration
|
||||
let springAnimation = makeSpringAnimation("sublayerTransform")
|
||||
let springAnimation = makeSpringAnimation("sublayerTransform", duration: duration)
|
||||
springAnimation.fromValue = NSValue(caTransform3D: CATransform3DMakeTranslation(0.0, -offset, 0.0))
|
||||
springAnimation.toValue = NSValue(caTransform3D: CATransform3DIdentity)
|
||||
springAnimation.isRemovedOnCompletion = true
|
||||
|
|
@ -3595,7 +3595,7 @@ open class ListView: ASDisplayNode, ASScrollViewDelegate, ASGestureRecognizerDel
|
|||
springAnimation.speed = speed * Float(springAnimation.duration / duration)
|
||||
}
|
||||
|
||||
let reverseSpringAnimation = makeSpringAnimation("sublayerTransform")
|
||||
let reverseSpringAnimation = makeSpringAnimation("sublayerTransform", duration: duration)
|
||||
reverseSpringAnimation.fromValue = NSValue(caTransform3D: CATransform3DMakeTranslation(0.0, offset, 0.0))
|
||||
reverseSpringAnimation.toValue = NSValue(caTransform3D: CATransform3DIdentity)
|
||||
reverseSpringAnimation.isRemovedOnCompletion = true
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ extension CGSize {
|
|||
}
|
||||
|
||||
private let springAnimationIn: CABasicAnimation = {
|
||||
let animation = makeSpringAnimation("")
|
||||
let animation = makeSpringAnimation("", duration: 0.5)
|
||||
return animation
|
||||
}()
|
||||
|
||||
|
|
|
|||
|
|
@ -8,8 +8,8 @@ public extension UIView {
|
|||
}
|
||||
}
|
||||
|
||||
public func makeSpringAnimation(_ keyPath: String) -> CABasicAnimation {
|
||||
return makeSpringAnimationImpl(keyPath)
|
||||
public func makeSpringAnimation(_ keyPath: String, duration: Double) -> CABasicAnimation {
|
||||
return makeSpringAnimationImpl(keyPath, duration)
|
||||
}
|
||||
|
||||
public func makeSpringBounceAnimation(_ keyPath: String, _ initialVelocity: CGFloat, _ damping: CGFloat) -> CABasicAnimation {
|
||||
|
|
|
|||
|
|
@ -376,11 +376,15 @@ public class GlassBackgroundView: UIView {
|
|||
nativeView.frame = CGRect(origin: CGPoint(), size: size)
|
||||
nativeContainerView.frame = CGRect(origin: CGPoint(), size: CGSize(width: size.width, height: max(size.height, 400.0)))
|
||||
} else {
|
||||
transition.containedViewLayoutTransition.animateView {
|
||||
/*transition.containedViewLayoutTransition.animateView {
|
||||
nativeView.layer.cornerRadius = cornerRadius
|
||||
nativeView.frame = CGRect(origin: CGPoint(), size: size)
|
||||
nativeContainerView.frame = CGRect(origin: CGPoint(), size: CGSize(width: size.width, height: max(size.height, 400.0)))
|
||||
}
|
||||
}*/
|
||||
nativeView.layer.cornerRadius = cornerRadius
|
||||
transition.setFrame(view: nativeView, frame: CGRect(origin: CGPoint(), size: size))
|
||||
transition.setFrame(view: nativeContainerView, frame: CGRect(origin: CGPoint(), size: CGSize(width: size.width, height: max(size.height, 400.0))))
|
||||
|
||||
//nativeView.layer.animateFrame(from: previousFrame, to: CGRect(origin: CGPoint(), size: size), duration: 0.4, timingFunction: kCAMediaTimingFunctionSpring)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
double animationDurationFactorImpl();
|
||||
|
||||
CABasicAnimation * _Nonnull makeSpringAnimationImpl(NSString * _Nonnull keyPath);
|
||||
CABasicAnimation * _Nonnull makeSpringAnimationImpl(NSString * _Nonnull keyPath, double duration);
|
||||
CABasicAnimation * _Nonnull make26SpringAnimationImpl(NSString * _Nonnull keyPath, double duration);
|
||||
CABasicAnimation * _Nonnull makeSpringBounceAnimationImpl(NSString * _Nonnull keyPath, CGFloat initialVelocity, CGFloat damping);
|
||||
CGFloat springAnimationValueAtImpl(CABasicAnimation * _Nonnull animation, CGFloat t);
|
||||
|
|
|
|||
|
|
@ -50,7 +50,11 @@ double animationDurationFactorImpl() {
|
|||
|
||||
@end
|
||||
|
||||
CABasicAnimation * _Nonnull makeSpringAnimationImpl(NSString * _Nonnull keyPath) {
|
||||
CABasicAnimation * _Nonnull makeSpringAnimationImpl(NSString * _Nonnull keyPath, double duration) {
|
||||
if (@available(iOS 26.0, *)) {
|
||||
return make26SpringAnimationImpl(keyPath, duration);
|
||||
}
|
||||
|
||||
CASpringAnimation *springAnimation = [CASpringAnimation animationWithKeyPath:keyPath];
|
||||
springAnimation.mass = 3.0f;
|
||||
springAnimation.stiffness = 1000.0f;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue