Skip to content

Instantly share code, notes, and snippets.

@victorBaro
Created May 5, 2015 23:25
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save victorBaro/89f26a7d787807b52c3b to your computer and use it in GitHub Desktop.
Save victorBaro/89f26a7d787807b52c3b to your computer and use it in GitHub Desktop.
Rubber band log10
@IBAction func viewDragged(sender: UIPanGestureRecognizer) {
let yTranslation = sender.translationInView(view).y
if (hasExceededVerticalLimit(topViewConstraint.constant)){
totalTranslation += yTranslation
topViewConstraint.constant = logConstraintValueForYPoisition(totalTranslation)
if(sender.state == UIGestureRecognizerState.Ended ){
animateViewBackToLimit()
}
} else {
topViewConstraint.constant += yTranslation
}
sender.setTranslation(CGPointZero, inView: view)
}
func logConstraintValueForYPoisition(yPosition : CGFloat) -> CGFloat {
return verticalLimit * (1 + log10(yPosition/verticalLimit))
}
@jacobvanorder
Copy link

There is a spelling error ("logConstraintValueForYPoisition"). I've corrected it here.

Great post!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment