1
1
mirror of https://github.com/exyte/Macaw.git synced 2024-08-15 16:10:39 +03:00

Remove content animation attempts

This commit is contained in:
Alisa Mylnikova 2019-05-15 16:26:59 +07:00
parent 94e52d6bd2
commit f3b07a6385
3 changed files with 10 additions and 18 deletions

View File

@ -7,10 +7,8 @@
//
class ShapeAnimation: AnimationImpl<Shape> {
let fromLayoutGlobalTransfrom: Transform
let toLayoutGlobalTransfrom: Transform
convenience init(animatedNode: Shape, finalValue: Shape, fromLayoutGlobalTransfrom: Transform = .identity, toLayoutGlobalTransfrom: Transform = .identity, animationDuration: Double, delay: Double = 0.0, autostart: Bool = false, fps: UInt = 30) {
convenience init(animatedNode: Shape, finalValue: Shape, animationDuration: Double, delay: Double = 0.0, autostart: Bool = false, fps: UInt = 30) {
let interpolationFunc = { (t: Double) -> Shape in
if t == 0 {
@ -20,12 +18,10 @@ class ShapeAnimation: AnimationImpl<Shape> {
return finalValue
}
self.init(animatedNode: animatedNode, valueFunc: interpolationFunc, fromLayoutGlobalTransfrom: fromLayoutGlobalTransfrom, toLayoutGlobalTransfrom: toLayoutGlobalTransfrom, animationDuration: animationDuration, delay: delay, autostart: autostart, fps: fps)
self.init(animatedNode: animatedNode, valueFunc: interpolationFunc, animationDuration: animationDuration, delay: delay, autostart: autostart, fps: fps)
}
init(animatedNode: Shape, valueFunc: @escaping (Double) -> Shape, fromLayoutGlobalTransfrom: Transform = .identity, toLayoutGlobalTransfrom: Transform = .identity, animationDuration: Double, delay: Double = 0.0, autostart: Bool = false, fps: UInt = 30) {
self.fromLayoutGlobalTransfrom = fromLayoutGlobalTransfrom
self.toLayoutGlobalTransfrom = toLayoutGlobalTransfrom
init(animatedNode: Shape, valueFunc: @escaping (Double) -> Shape, animationDuration: Double, delay: Double = 0.0, autostart: Bool = false, fps: UInt = 30) {
super.init(observableValue: AnimatableVariable<Shape>(animatedNode), valueFunc: valueFunc, animationDuration: animationDuration, delay: delay, fps: fps)
type = .shape
node = animatedNode
@ -35,9 +31,7 @@ class ShapeAnimation: AnimationImpl<Shape> {
}
}
init(animatedNode: Shape, factory: @escaping (() -> ((Double) -> Shape)), fromLayoutGlobalTransfrom: Transform = .identity, toLayoutGlobalTransfrom: Transform = .identity, animationDuration: Double, delay: Double = 0.0, autostart: Bool = false, fps: UInt = 30) {
self.fromLayoutGlobalTransfrom = fromLayoutGlobalTransfrom
self.toLayoutGlobalTransfrom = toLayoutGlobalTransfrom
init(animatedNode: Shape, factory: @escaping (() -> ((Double) -> Shape)), animationDuration: Double, delay: Double = 0.0, autostart: Bool = false, fps: UInt = 30) {
super.init(observableValue: AnimatableVariable<Shape>(animatedNode), factory: factory, animationDuration: animationDuration, delay: delay, fps: fps)
type = .shape
node = animatedNode

View File

@ -13,7 +13,7 @@ import AppKit
extension AnimationProducer {
func createChildAnimations(_ combineAnimation: Animation, fromLayoutGlobalTransfrom: Transform, toLayoutGlobalTransfrom: Transform, animations: [Animation] = []) -> [Animation] {
func createChildAnimations(_ combineAnimation: Animation, animations: [Animation] = []) -> [Animation] {
guard let combine = combineAnimation as? CombineAnimation else {
return animations
}
@ -36,7 +36,7 @@ extension AnimationProducer {
let fromShape = fromShapes[i]
let toShape = toShapes[i]
let animation = ShapeAnimation(animatedNode: fromShape, finalValue: toShape, fromLayoutGlobalTransfrom: fromLayoutGlobalTransfrom, toLayoutGlobalTransfrom: toLayoutGlobalTransfrom, animationDuration: during, delay: delay)
let animation = ShapeAnimation(animatedNode: fromShape, finalValue: toShape, animationDuration: during, delay: delay)
animations.append(animation)
}
@ -68,7 +68,7 @@ extension AnimationProducer {
let toGroup = toGroups[i]
let groupAnimation = fromGroup.contentsVar.animation(to: toGroup.contents, during: during, delay: delay)
let groupAnimations = createChildAnimations(groupAnimation, fromLayoutGlobalTransfrom: fromLayoutGlobalTransfrom, toLayoutGlobalTransfrom: toLayoutGlobalTransfrom, animations: animations)
let groupAnimations = createChildAnimations(groupAnimation, animations: animations)
animations.append(contentsOf: groupAnimations)
}
@ -122,9 +122,7 @@ extension AnimationProducer {
var animations = combine.animations
if let fromBounds = combine.node?.bounds, let toBounds = combine.toNodes.group().bounds {
let fromLayoutTransform = view.contentLayout.layout(rect: fromBounds, into: view.frame.size.toMacaw())
let toLayoutTransform = view.contentLayout.layout(rect: toBounds, into: view.frame.size.toMacaw())
let childAnimations = createChildAnimations(combine, fromLayoutGlobalTransfrom: fromLayoutTransform, toLayoutGlobalTransfrom: toLayoutTransform) as! [BasicAnimation]
let childAnimations = createChildAnimations(combine) as! [BasicAnimation]
animations.append(contentsOf: childAnimations)
}

View File

@ -131,8 +131,8 @@ fileprivate func generateShapeAnimation(_ context: AnimationContext, from: Shape
// Transform
let transformAnimation = CABasicAnimation(keyPath: "transform")
transformAnimation.duration = duration
transformAnimation.fromValue = CATransform3DMakeAffineTransform(animation.fromLayoutGlobalTransfrom.concat(with: from.place).toCG())
transformAnimation.toValue = CATransform3DMakeAffineTransform(animation.toLayoutGlobalTransfrom.concat(with: to.place).toCG())
transformAnimation.fromValue = CATransform3DMakeAffineTransform(from.place.toCG())
transformAnimation.toValue = CATransform3DMakeAffineTransform(to.place.toCG())
group.animations?.append(transformAnimation)