Files
session-ios/Session/Utilities/UIScrollView+Utilities.swift
Morgan Pretty 62c886e764 Got paging working on the conversation screen
Fixed a couple of issues where attachment messages would flicker due to thread changing
Fixed a couple of issues with page loading
Connected the global search result select back up
2022-05-26 18:13:16 +10:00

38 lines
1.1 KiB
Swift

// Copyright © 2022 Rangeproof Pty Ltd. All rights reserved.
import UIKit
public extension UIScrollView {
static let fastEndScrollingThen: ((UIScrollView, CGPoint?, @escaping () -> ()) -> ()) = { scrollView, currentTargetOffset, callback in
let endOffset: CGPoint
if let currentTargetOffset: CGPoint = currentTargetOffset {
endOffset = currentTargetOffset
}
else {
let currentVelocity: CGPoint = scrollView.panGestureRecognizer.velocity(in: scrollView)
endOffset = CGPoint(
x: scrollView.contentOffset.x,
y: scrollView.contentOffset.y - (currentVelocity.y / 100)
)
}
guard endOffset != scrollView.contentOffset else {
return callback()
}
UIView.animate(
withDuration: 0.1,
delay: 0,
options: .curveEaseOut,
animations: {
scrollView.setContentOffset(endOffset, animated: false)
},
completion: { _ in
callback()
}
)
}
}