Forked from victorBaro/gist:89f26a7d787807b52c3b
Last active
August 29, 2015 14:22
-
-
Save jacobvanorder/5ee33254b81357a870b5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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