Skip to content

Commit

Permalink
Updated to support Swift 3 release
Browse files Browse the repository at this point in the history
  • Loading branch information
poetmountain committed Sep 15, 2016
1 parent 7f800c6 commit d7fd3f6
Show file tree
Hide file tree
Showing 51 changed files with 1,464 additions and 1,461 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
#### 1.1.0
Support for Swift 3.0.

#### 1.0.0
Initial release
2 changes: 1 addition & 1 deletion Classes/CATempo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public class CATempo : Tempo {
public override init() {
super.init()
displayLink = CADisplayLink.init(target: self, selector: #selector(update))
displayLink?.addToRunLoop(NSRunLoop.mainRunLoop(), forMode: NSRunLoopCommonModes)
displayLink?.add(to: RunLoop.main, forMode: RunLoopMode(rawValue: RunLoopMode.commonModes.rawValue))
}

deinit {
Expand Down
8 changes: 4 additions & 4 deletions Classes/EasingTypes/EasingBack.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public struct EasingBack {
*/
public static func easeIn(overshoot over: Double=0.1) -> EasingUpdateClosure {

func easing (elapsedTime: NSTimeInterval, startValue: Double, valueRange: Double, duration: NSTimeInterval) -> Double {
func easing (_ elapsedTime: TimeInterval, startValue: Double, valueRange: Double, duration: TimeInterval) -> Double {
let time = elapsedTime / duration
let overshoot = over * magic100
let easing_value = valueRange * time*time*((overshoot + 1.0)*time - overshoot) + startValue
Expand All @@ -60,7 +60,7 @@ public struct EasingBack {
*/
public static func easeOut(overshoot over: Double=0.1) -> EasingUpdateClosure {

func easing (elapsedTime: NSTimeInterval, startValue: Double, valueRange: Double, duration: NSTimeInterval) -> Double {
func easing (_ elapsedTime: TimeInterval, startValue: Double, valueRange: Double, duration: TimeInterval) -> Double {
let time = elapsedTime / duration - 1
let overshoot = over * magic100
let easing_value = valueRange * (time*time * ((overshoot+1.0) * time + overshoot) + 1.0) + startValue
Expand All @@ -78,7 +78,7 @@ public struct EasingBack {
*/
public static func easeInOut(overshoot over: Double=0.1) -> EasingUpdateClosure {

func easing (elapsedTime: NSTimeInterval, startValue: Double, valueRange: Double, duration: NSTimeInterval) -> Double {
func easing (_ elapsedTime: TimeInterval, startValue: Double, valueRange: Double, duration: TimeInterval) -> Double {
var easing_value = 0.0
var time = elapsedTime / (duration * 0.5)
let overshoot = (over * magic100) * 1.525
Expand All @@ -97,4 +97,4 @@ public struct EasingBack {
return easing
}

}
}
14 changes: 7 additions & 7 deletions Classes/EasingTypes/EasingBounce.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ public struct EasingBounce {

public static func easeIn() -> EasingUpdateClosure {

func easing (elapsedTime: NSTimeInterval, startValue: Double, valueRange: Double, duration: NSTimeInterval) -> Double {
func easing (_ elapsedTime: TimeInterval, startValue: Double, valueRange: Double, duration: TimeInterval) -> Double {

let easing_closure = EasingBounce.easeOut()
let time = duration - elapsedTime
let easing_value = valueRange - easing_closure(elapsedTime: time, startValue: 0.0, valueRange: valueRange, duration: duration) + startValue
let easing_value = valueRange - easing_closure(time, 0.0, valueRange, duration) + startValue

return easing_value
}
Expand All @@ -50,7 +50,7 @@ public struct EasingBounce {

public static func easeOut() -> EasingUpdateClosure {

func easing (elapsedTime: NSTimeInterval, startValue: Double, valueRange: Double, duration: NSTimeInterval) -> Double {
func easing (_ elapsedTime: TimeInterval, startValue: Double, valueRange: Double, duration: TimeInterval) -> Double {
var time = elapsedTime / duration
let easing_value: Double
if (time < (1/2.75)) {
Expand All @@ -74,14 +74,14 @@ public struct EasingBounce {

public static func easeInOut() -> EasingUpdateClosure {

func easing (elapsedTime: NSTimeInterval, startValue: Double, valueRange: Double, duration: NSTimeInterval) -> Double {
func easing (_ elapsedTime: TimeInterval, startValue: Double, valueRange: Double, duration: TimeInterval) -> Double {
let easing_value: Double
let easing_closure = EasingBounce.easeOut()

if (elapsedTime < (duration * 0.5)) {
easing_value = easing_closure(elapsedTime: (elapsedTime*2), startValue: 0, valueRange: valueRange, duration: duration) * 0.5 + startValue;
easing_value = easing_closure((elapsedTime*2), 0, valueRange, duration) * 0.5 + startValue;
} else {
easing_value = easing_closure(elapsedTime: (elapsedTime*2-duration), startValue: 0, valueRange: valueRange, duration: duration) * 0.5 + (valueRange*0.5) + startValue;
easing_value = easing_closure((elapsedTime*2-duration), 0, valueRange, duration) * 0.5 + (valueRange*0.5) + startValue;
}


Expand All @@ -91,4 +91,4 @@ public struct EasingBounce {
return easing
}

}
}
8 changes: 4 additions & 4 deletions Classes/EasingTypes/EasingCircular.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public struct EasingCircular {

public static func easeIn() -> EasingUpdateClosure {

func easing (elapsedTime: NSTimeInterval, startValue: Double, valueRange: Double, duration: NSTimeInterval) -> Double {
func easing (_ elapsedTime: TimeInterval, startValue: Double, valueRange: Double, duration: TimeInterval) -> Double {
let time = elapsedTime / duration
let easing_value = -valueRange * (sqrt(1 - time*time) - 1) + startValue

Expand All @@ -45,7 +45,7 @@ public struct EasingCircular {

public static func easeOut() -> EasingUpdateClosure {

func easing (elapsedTime: NSTimeInterval, startValue: Double, valueRange: Double, duration: NSTimeInterval) -> Double {
func easing (_ elapsedTime: TimeInterval, startValue: Double, valueRange: Double, duration: TimeInterval) -> Double {
var time = elapsedTime / duration
time -= 1
let easing_value = valueRange * sqrt(1 - time*time) + startValue
Expand All @@ -58,7 +58,7 @@ public struct EasingCircular {

public static func easeInOut() -> EasingUpdateClosure {

func easing (elapsedTime: NSTimeInterval, startValue: Double, valueRange: Double, duration: NSTimeInterval) -> Double {
func easing (_ elapsedTime: TimeInterval, startValue: Double, valueRange: Double, duration: TimeInterval) -> Double {
var easing_value = 0.0
var time = elapsedTime / (duration * 0.5)

Expand All @@ -76,4 +76,4 @@ public struct EasingCircular {
return easing
}

}
}
8 changes: 4 additions & 4 deletions Classes/EasingTypes/EasingCubic.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public struct EasingCubic {

public static func easeIn() -> EasingUpdateClosure {

func easing (elapsedTime: NSTimeInterval, startValue: Double, valueRange: Double, duration: NSTimeInterval) -> Double {
func easing (_ elapsedTime: TimeInterval, startValue: Double, valueRange: Double, duration: TimeInterval) -> Double {
let time = elapsedTime / duration
let easing_value = valueRange * (time*time*time) + startValue

Expand All @@ -45,7 +45,7 @@ public struct EasingCubic {

public static func easeOut() -> EasingUpdateClosure {

func easing (elapsedTime: NSTimeInterval, startValue: Double, valueRange: Double, duration: NSTimeInterval) -> Double {
func easing (_ elapsedTime: TimeInterval, startValue: Double, valueRange: Double, duration: TimeInterval) -> Double {
var time = elapsedTime / duration
time -= 1
let easing_value = valueRange * (time*time*time + 1) + startValue
Expand All @@ -58,7 +58,7 @@ public struct EasingCubic {

public static func easeInOut() -> EasingUpdateClosure {

func easing (elapsedTime: NSTimeInterval, startValue: Double, valueRange: Double, duration: NSTimeInterval) -> Double {
func easing (_ elapsedTime: TimeInterval, startValue: Double, valueRange: Double, duration: TimeInterval) -> Double {
var time = elapsedTime / (duration * 0.5)
var easing_value = 0.0
if (time < 1) {
Expand All @@ -75,4 +75,4 @@ public struct EasingCubic {
return easing
}

}
}
11 changes: 6 additions & 5 deletions Classes/EasingTypes/EasingElastic.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public struct EasingElastic {

public static func easeIn() -> EasingUpdateClosure {

func easing (elapsedTime: NSTimeInterval, startValue: Double, valueRange: Double, duration: NSTimeInterval) -> Double {
func easing (_ elapsedTime: TimeInterval, startValue: Double, valueRange: Double, duration: TimeInterval) -> Double {
var time = elapsedTime
var easing_value = 0.0

Expand Down Expand Up @@ -63,7 +63,7 @@ public struct EasingElastic {

public static func easeOut() -> EasingUpdateClosure {

func easing (elapsedTime: NSTimeInterval, startValue: Double, valueRange: Double, duration: NSTimeInterval) -> Double {
func easing (_ elapsedTime: TimeInterval, startValue: Double, valueRange: Double, duration: TimeInterval) -> Double {
var time = elapsedTime
var easing_value = 0.0
if (time ≈≈ 0.0) {
Expand All @@ -89,7 +89,7 @@ public struct EasingElastic {

public static func easeInOut() -> EasingUpdateClosure {

func easing (elapsedTime: NSTimeInterval, startValue: Double, valueRange: Double, duration: NSTimeInterval) -> Double {
func easing (_ elapsedTime: TimeInterval, startValue: Double, valueRange: Double, duration: TimeInterval) -> Double {
var time = elapsedTime
var easing_value = 0.0

Expand All @@ -111,7 +111,8 @@ public struct EasingElastic {
} else {

time -= 1
easing_value = amplitude*pow(2, -10*time) * sin( (time*duration-overshoot) * M_PI2/period ) * 0.5 + valueRange + startValue
easing_value = amplitude*pow(2, -10*time) * sin( (time*duration-overshoot) * M_PI2/period ) * 0.5
easing_value += valueRange + startValue
}
}

Expand All @@ -122,4 +123,4 @@ public struct EasingElastic {
return easing
}

}
}
16 changes: 10 additions & 6 deletions Classes/EasingTypes/EasingExpo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public struct EasingExpo {

public static func easeIn() -> EasingUpdateClosure {

func easing (elapsedTime: NSTimeInterval, startValue: Double, valueRange: Double, duration: NSTimeInterval) -> Double {
func easing (_ elapsedTime: TimeInterval, startValue: Double, valueRange: Double, duration: TimeInterval) -> Double {
let easing_value = (elapsedTime == 0) ? startValue : valueRange * pow(2, 10 * (elapsedTime/duration - 1)) + startValue

return easing_value
Expand All @@ -44,9 +44,13 @@ public struct EasingExpo {

public static func easeOut() -> EasingUpdateClosure {

func easing (elapsedTime: NSTimeInterval, startValue: Double, valueRange: Double, duration: NSTimeInterval) -> Double {
let easing_value = (elapsedTime == duration) ? startValue+valueRange : valueRange * (-pow(2, -10 * elapsedTime/duration) + 1) + startValue

func easing (_ elapsedTime: TimeInterval, startValue: Double, valueRange: Double, duration: TimeInterval) -> Double {
var easing_value = 0.0
if (elapsedTime == duration) {
easing_value = startValue+valueRange
} else {
easing_value = valueRange * (-pow(2, -10 * elapsedTime/duration) + 1) + startValue
}
return easing_value
}

Expand All @@ -55,7 +59,7 @@ public struct EasingExpo {

public static func easeInOut() -> EasingUpdateClosure {

func easing (elapsedTime: NSTimeInterval, startValue: Double, valueRange: Double, duration: NSTimeInterval) -> Double {
func easing (_ elapsedTime: TimeInterval, startValue: Double, valueRange: Double, duration: TimeInterval) -> Double {
var easing_value = 0.0
var time = elapsedTime

Expand Down Expand Up @@ -83,4 +87,4 @@ public struct EasingExpo {
return easing
}

}
}
2 changes: 1 addition & 1 deletion Classes/EasingTypes/EasingLinear.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public struct EasingLinear {

public static func easeNone() -> EasingUpdateClosure {

func easing (elapsedTime: NSTimeInterval, startValue: Double, valueRange: Double, duration: NSTimeInterval) -> Double {
func easing (_ elapsedTime: TimeInterval, startValue: Double, valueRange: Double, duration: TimeInterval) -> Double {
let easing_value = valueRange * (elapsedTime / duration) + startValue

return easing_value
Expand Down
10 changes: 5 additions & 5 deletions Classes/EasingTypes/EasingQuadratic.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public struct EasingQuadratic {

public static func easeIn() -> EasingUpdateClosure {

func easing (elapsedTime: NSTimeInterval, startValue: Double, valueRange: Double, duration: NSTimeInterval) -> Double {
func easing (_ elapsedTime: TimeInterval, startValue: Double, valueRange: Double, duration: TimeInterval) -> Double {
let easing_value = valueRange * (elapsedTime*elapsedTime) / (duration*duration) + startValue

return easing_value
Expand All @@ -44,8 +44,8 @@ public struct EasingQuadratic {

public static func easeOut() -> EasingUpdateClosure {

func easing (elapsedTime: NSTimeInterval, startValue: Double, valueRange: Double, duration: NSTimeInterval) -> Double {
let easing_value = -valueRange * (elapsedTime*elapsedTime) / (duration*duration) + 2*valueRange*elapsedTime/duration + startValue
func easing (_ elapsedTime: TimeInterval, startValue: Double, valueRange: Double, duration: TimeInterval) -> Double {
let easing_value = -valueRange * ((elapsedTime*elapsedTime) / (duration*duration)) + (2*valueRange * (elapsedTime/duration)) + startValue

return easing_value
}
Expand All @@ -55,7 +55,7 @@ public struct EasingQuadratic {

public static func easeInOut() -> EasingUpdateClosure {

func easing (elapsedTime: NSTimeInterval, startValue: Double, valueRange: Double, duration: NSTimeInterval) -> Double {
func easing (_ elapsedTime: TimeInterval, startValue: Double, valueRange: Double, duration: TimeInterval) -> Double {
let easing_value: Double
if (elapsedTime < duration*0.5) {
easing_value = 2*valueRange * (elapsedTime*elapsedTime) / (duration*duration) + startValue
Expand All @@ -70,4 +70,4 @@ public struct EasingQuadratic {
return easing
}

}
}
6 changes: 3 additions & 3 deletions Classes/EasingTypes/EasingQuartic.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public struct EasingQuartic {

public static func easeIn() -> EasingUpdateClosure {

func easing (elapsedTime: NSTimeInterval, startValue: Double, valueRange: Double, duration: NSTimeInterval) -> Double {
func easing (_ elapsedTime: TimeInterval, startValue: Double, valueRange: Double, duration: TimeInterval) -> Double {
let time = elapsedTime / duration
let easing_value = valueRange * (time*time*time*time) + startValue

Expand All @@ -45,7 +45,7 @@ public struct EasingQuartic {

public static func easeOut() -> EasingUpdateClosure {

func easing (elapsedTime: NSTimeInterval, startValue: Double, valueRange: Double, duration: NSTimeInterval) -> Double {
func easing (_ elapsedTime: TimeInterval, startValue: Double, valueRange: Double, duration: TimeInterval) -> Double {
var time = elapsedTime / duration
time -= 1
let easing_value = -valueRange * (time*time*time*time - 1) + startValue
Expand All @@ -58,7 +58,7 @@ public struct EasingQuartic {

public static func easeInOut() -> EasingUpdateClosure {

func easing (elapsedTime: NSTimeInterval, startValue: Double, valueRange: Double, duration: NSTimeInterval) -> Double {
func easing (_ elapsedTime: TimeInterval, startValue: Double, valueRange: Double, duration: TimeInterval) -> Double {
var time = elapsedTime / (duration * 0.5)

var easing_value = 0.0
Expand Down
8 changes: 4 additions & 4 deletions Classes/EasingTypes/EasingQuintic.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public struct EasingQuintic {

public static func easeIn() -> EasingUpdateClosure {

func easing (elapsedTime: NSTimeInterval, startValue: Double, valueRange: Double, duration: NSTimeInterval) -> Double {
func easing (_ elapsedTime: TimeInterval, startValue: Double, valueRange: Double, duration: TimeInterval) -> Double {
let time = elapsedTime / duration
let easing_value = valueRange * (time*time*time*time*time) + startValue

Expand All @@ -45,7 +45,7 @@ public struct EasingQuintic {

public static func easeOut() -> EasingUpdateClosure {

func easing (elapsedTime: NSTimeInterval, startValue: Double, valueRange: Double, duration: NSTimeInterval) -> Double {
func easing (_ elapsedTime: TimeInterval, startValue: Double, valueRange: Double, duration: TimeInterval) -> Double {
var time = elapsedTime / duration
time -= 1
let easing_value = valueRange * (time*time*time*time*time + 1) + startValue
Expand All @@ -58,7 +58,7 @@ public struct EasingQuintic {

public static func easeInOut() -> EasingUpdateClosure {

func easing (elapsedTime: NSTimeInterval, startValue: Double, valueRange: Double, duration: NSTimeInterval) -> Double {
func easing (_ elapsedTime: TimeInterval, startValue: Double, valueRange: Double, duration: TimeInterval) -> Double {
var time = elapsedTime / (duration * 0.5)

var easing_value = 0.0
Expand All @@ -76,4 +76,4 @@ public struct EasingQuintic {
return easing
}

}
}
11 changes: 6 additions & 5 deletions Classes/EasingTypes/EasingSine.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public struct EasingSine {

public static func easeIn() -> EasingUpdateClosure {

func easing (elapsedTime: NSTimeInterval, startValue: Double, valueRange: Double, duration: NSTimeInterval) -> Double {
func easing (_ elapsedTime: TimeInterval, startValue: Double, valueRange: Double, duration: TimeInterval) -> Double {
let easing_value = -valueRange * cos((elapsedTime / duration) * M_PI_2) + valueRange + startValue

return easing_value
Expand All @@ -44,7 +44,7 @@ public struct EasingSine {

public static func easeOut() -> EasingUpdateClosure {

func easing (elapsedTime: NSTimeInterval, startValue: Double, valueRange: Double, duration: NSTimeInterval) -> Double {
func easing (_ elapsedTime: TimeInterval, startValue: Double, valueRange: Double, duration: TimeInterval) -> Double {
let easing_value = valueRange * sin((elapsedTime / duration) * M_PI_2) + startValue

return easing_value
Expand All @@ -55,13 +55,14 @@ public struct EasingSine {

public static func easeInOut() -> EasingUpdateClosure {

func easing (elapsedTime: NSTimeInterval, startValue: Double, valueRange: Double, duration: NSTimeInterval) -> Double {
let easing_value = (-valueRange * 0.5) * (cos(M_PI * (elapsedTime / duration)) - 1) + startValue
func easing (_ elapsedTime: TimeInterval, startValue: Double, valueRange: Double, duration: TimeInterval) -> Double {
var easing_value = (-valueRange * 0.5) * (cos(M_PI * (elapsedTime / duration)) - 1)
easing_value += startValue

return easing_value
}

return easing
}

}
}
Loading

0 comments on commit d7fd3f6

Please sign in to comment.