, :
let viewHeight: CGFloat = 80.0
func scrollViewWillBeginDragging(scrollView: UIScrollView) {
startContentOffsetY = scrollView.contentOffset.y
}
func scrollViewWillEndDragging(scrollView: UIScrollView, withVelocity velocity: CGPoint, targetContentOffset: UnsafeMutablePointer<CGPoint>) {
targetContentOffsetY = targetContentOffset.memory.y
if startContentOffsetY - targetContentOffsetY < 0 {
scrollDirection = ScrollDirection.Bottom.rawValue
} else {
scrollDirection = ScrollDirection.Top.rawValue
}
let gap = targetContentOffsetY % viewHeight
var offset: CGFloat = 0.0
if (targetContentOffsetY - gap) % viewHeight == 0 {
offset = -gap * scrollDirection
} else {
offset = gap * scrollDirection
}
let newTarget = targetContentOffsetY + (offset * scrollDirection)
targetContentOffset.memory.y = newTarget
}