1
1
mirror of https://github.com/exyte/Macaw.git synced 2024-10-10 19:37:32 +03:00

Helpful extensions

This commit is contained in:
Victor Sukochev 2016-04-01 14:58:14 +06:00
parent 4329fd738d
commit 23594868c6
5 changed files with 38 additions and 4 deletions

View File

@ -143,10 +143,9 @@ class ThirdPageCustomView: MacawView {
finalValue:Transform.move(220, my: 420).scale(0.15, sy: 0.15),
animationDuration: 1.5)
let animationSequence = AnimationSequence(animations: [cloud1ShapeAnimation, cloud2ShapeAnimation, cloud3ShapeAnimation])
let loopedAnimation = LoopedAnimation(animation:animationSequence)
let animationLoop = RepetitiveAnimation(animation: loopedAnimation)
super.addAnimation(animationLoop)
let animation = [cloud1ShapeAnimation, cloud2ShapeAnimation, cloud3ShapeAnimation].sequence().looped().infiniteLoop()
super.addAnimation(animation)
// super.addAnimation(cloud1ShapeAnimation)
// super.addAnimation(cloud2ShapeAnimation)
// super.addAnimation(cloud3ShapeAnimation)

View File

@ -1,5 +1,16 @@
import Foundation
public extension SequenceType where Generator.Element: CommonAnimation{
public func sequence() -> CommonAnimation {
let sequence = AnimationSequence(animations:[])
self.forEach { animation in
sequence.addAnimation(animation)
}
return sequence
}
}
public class AnimationSequence: CommonAnimation {
var sequence: [CommonAnimation] = []

View File

@ -1,5 +1,11 @@
import Foundation
public extension CommonAnimation {
public func looped() -> CommonAnimation {
return LoopedAnimation(animation: self)
}
}
public class LoopedAnimation: CommonAnimation {
var loopedlAnimation: CommonAnimation?

View File

@ -1,10 +1,21 @@
import Foundation
public enum RepetitiveAnimationType {
case Finite
case Infinite
}
public extension CommonAnimation {
public func infiniteLoop() -> CommonAnimation {
return RepetitiveAnimation(animation: self)
}
public func loop(count: Int) -> CommonAnimation {
return RepetitiveAnimation(animation: self, count: count)
}
}
public class RepetitiveAnimation: CommonAnimation {
var loopAnimation: CommonAnimation?

View File

@ -1,5 +1,12 @@
import Foundation
public extension CommonAnimation {
public func revert() -> CommonAnimation {
return RevertedAnimation(animation: self)
}
}
public class RevertedAnimation: CommonAnimation {
var originalAnimation: CommonAnimation?