In the gesture recognizer method, we handle the `.Ended`

state by computing the following:

- the target point we are going to animate to
- the view's current velocity in its parent, given to us by
`UIPanGestureRecognizer`

- the overall distance we need to travel
- the relative distance our velocity vector makes up

Using these values, we can calculate our spring animations initial velocity:

```
case .Ended:
let velocity = recognizer.velocityInView(parent)
print(velocity)
let targetPoint = computeTargetPoint(view, location: centerInParent, velocity: velocity, bounds: parent.bounds)
func magnitude(vector: CGPoint) -> CGFloat {
return sqrt(pow(vector.x, 2) + pow(vector.y, 2))
}
let distanceVector = CGPoint(x: centerInParent.x - targetPoint.x, y: centerInParent.y - targetPoint.y)
let totalDistance = magnitude(distanceVector)
let magVelocity = magnitude(velocity)
let animationDuration: NSTimeInterval = 1
let springVelocity: CGFloat = magVelocity / totalDistance / CGFloat(animationDuration)
UIView.animateWithDuration(animationDuration,
delay: 0,
usingSpringWithDamping: 0.9,
initialSpringVelocity: springVelocity,
options: [],
animations: {
recognizer.view!.center = targetPoint
}, completion: nil)
```

This episode uses Xcode 7.3, Swift 2.3.