Last active
May 27, 2016 02:33
-
-
Save pingzh/924d67119351f513ebe8 to your computer and use it in GitHub Desktop.
This file contains 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
func onPanGesture(sender: UIPanGestureRecognizer) { | |
let translation = sender.translationInView(view) | |
let velocity = sender.velocityInView(view) | |
if sender.state == UIGestureRecognizerState.Began { | |
} | |
else if sender.state == UIGestureRecognizerState.Changed { | |
contentView.snp_updateConstraints(closure: { (make) -> Void in | |
make.left.equalTo(view).offset(translation.x) | |
}) | |
} | |
else if sender.state == UIGestureRecognizerState.Ended { | |
UIView.animateWithDuration(0.3, animations: { | |
if velocity.x > 0 { | |
self.contentView.snp_updateConstraints(closure: { (make) -> Void in | |
make.left.equalTo(self.view).offset(TWMenuWidth) | |
}) | |
} | |
else { | |
self.contentView.snp_updateConstraints(closure: { (make) -> Void in | |
make.left.equalTo(self.view).offset(0) | |
}) | |
} | |
}) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment