Created
August 15, 2016 12:20
-
-
Save hudinwal/8e3b49b5c4c06cdb0b3b26b7e2b35383 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
extension ViewController : UIScrollViewDelegate,UITableViewDelegate { | |
func scrollViewWillEndDragging(scrollView: UIScrollView, withVelocity velocity: CGPoint, targetContentOffset: UnsafeMutablePointer<CGPoint>) { | |
let yInset = scrollView.contentInset.top | |
if scrollView.contentOffset.y > -topOffset && targetContentOffset.memory.y < -topOffset { | |
targetContentOffset.memory.y = scrollView.contentOffset.y | |
scrollView.setContentOffset(CGPointMake(0, -topOffset), animated: true) | |
} | |
else if -topOffset > targetContentOffset.memory.y && targetContentOffset.memory.y > (-topOffset + (topOffset - yInset)/2) { | |
targetContentOffset.memory.y = scrollView.contentOffset.y | |
scrollView.setContentOffset(CGPointMake(0, -topOffset), animated: true) | |
} | |
else if (-topOffset + (topOffset - yInset)/2) > targetContentOffset.memory.y { | |
targetContentOffset.memory.y = scrollView.contentOffset.y | |
scrollView.setContentOffset(CGPointMake(0, -yInset), animated: true) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment