Skip to content

Instantly share code, notes, and snippets.

@jacobvanorder
Forked from victorBaro/gist:89f26a7d787807b52c3b
Last active August 29, 2015 14:22
Show Gist options
  • Save jacobvanorder/5ee33254b81357a870b5 to your computer and use it in GitHub Desktop.
Save jacobvanorder/5ee33254b81357a870b5 to your computer and use it in GitHub Desktop.
@IBAction func viewDragged(sender: UIPanGestureRecognizer) {
let yTranslation = sender.translationInView(view).y
if (hasExceededVerticalLimit(topViewConstraint.constant)){
totalTranslation += yTranslation
topViewConstraint.constant = logConstraintValueForYPosition(totalTranslation)
if(sender.state == UIGestureRecognizerState.Ended ){
animateViewBackToLimit()
}
} else {
topViewConstraint.constant += yTranslation
}
sender.setTranslation(CGPointZero, inView: view)
}
func logConstraintValueForYPosition(yPosition : CGFloat) -> CGFloat {
return verticalLimit * (1 + log10(yPosition/verticalLimit))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment