Commit add47a64 authored by toby's avatar toby

update animate background state

parent d5b3a3ff
......@@ -10,11 +10,11 @@ import UIKit
enum BackgroundState:StateMachineDataSource{
case Ready, Animating, Paused, Finished
case Ready, AnimatingBackground, Paused, Finished
func shouldTransitionFrom(from:BackgroundState, to: BackgroundState) -> Should<BackgroundState>{
func shouldTransitionFrom(from:BackgroundState, to: BackgroundState) -> Should {
switch (from, to){
case (.Ready, .Animating), (.Paused, .Animating), (.Animating, .Paused), (.Animating, .Finished), (.Paused, .Finished), (.Finished, .Animating):
case (.Ready, .AnimatingBackground), (.Paused, .AnimatingBackground), (.AnimatingBackground, .Paused), (.AnimatingBackground, .Finished), (.Paused, .Finished), (.Finished, .AnimatingBackground):
return .Continue
default:
return .Abort
......@@ -29,14 +29,14 @@ extension ViewController: StateMachineDelegate {
func didTransitionFrom(from: StateType, to: StateType) {
switch (from, to) {
case (.Ready, .Animating), (.Finished, .Animating):
case (.Ready, .AnimatingBackground), (.Finished, .AnimatingBackground):
animateBackground()
case (.Animating, .Paused):
case (.AnimatingBackground, .Paused):
background.pause()
case (.Paused, .Animating), (.Paused, .Finished):
case (.Paused, .AnimatingBackground), (.Paused, .Finished):
background.unpause()
case (.Animating, .Finished):
machine.state = .Animating
case (.AnimatingBackground, .Finished):
machine.state = .AnimatingBackground
default:
break
}
......@@ -186,7 +186,7 @@ class ViewController: UIViewController {
@IBAction func backgroundHeld(hold: UILongPressGestureRecognizer) {
switch hold.state {
case UIGestureRecognizerState.Began:
machine.state = .Animating
machine.state = .AnimatingBackground
case UIGestureRecognizerState.Ended:
machine.state = .Paused
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment