Skip to content

Instantly share code, notes, and snippets.

View rchatham's full-sized avatar
👨‍💻
code code code...

Reid Chatham rchatham

👨‍💻
code code code...
View GitHub Profile
@rchatham
rchatham / dequeue-animations.swift
Last active December 6, 2016 02:34
Performing Queued animations
func perform() {
guard let animation = animations.dequeue else { return }
UIView.animate(withDuration: animation.0, animations: animation.1) { success in
perform()
}
}
@rchatham
rchatham / enqueue-animations.swift
Created December 6, 2016 02:28
Queueing animations
typealias Animation = (TimeInterval, ()->Void)
let animation: Animation = (5.0, {
// Code to animate
})
let animations = Queue<Animation>()
animations.enqueue(animation)
@rchatham
rchatham / queue.swift
Created December 6, 2016 02:01
Queue using Node's in Swift
internal class Node<T> {
var data: T
var next: Node<T>?
init(data: T) {
self.data = data
}
}
internal struct Queue<T> {
var first, last: Node<T>?
@rchatham
rchatham / animations-with-SwiftyAnimate.swift
Created December 6, 2016 01:59
Chaining animations with SwiftyAnimate
// Escape the Pyramid of DOOM!
Animate(duration: time) { [unowned self] in
// animation
self.animationFunction()
}.do { [unowned self] in
// non-animation function
self.nonAnimationFunction()
}.then(duration: time) { [unowned self] in
// animation
self.animationFunction()
@rchatham
rchatham / pyramid-of-DOOM.swift
Created December 6, 2016 01:56
Chaining UIView animations
UIView.animate(withDuration: time, animations: { [unowned self] in
// animation
self.animationFunction()
}) { [unowned self] success in
// non-animation function
self.nonAnimationFunction()
UIView.animate(withDuration: time, animations: {
// animation
self.animationFunction()
}) { success in