mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-23 22:55:00 +00:00
Ads and codes improvements
This commit is contained in:
@@ -7,6 +7,7 @@ public final class WindowPanRecognizer: UIGestureRecognizer {
|
||||
public var ended: ((CGPoint, CGPoint?) -> Void)?
|
||||
|
||||
private var previousPoints: [(CGPoint, Double)] = []
|
||||
private var previousVelocity: CGFloat = 0.0
|
||||
|
||||
override public func reset() {
|
||||
super.reset()
|
||||
@@ -45,6 +46,11 @@ public final class WindowPanRecognizer: UIGestureRecognizer {
|
||||
}
|
||||
}
|
||||
|
||||
func velocity(in view: UIView?) -> CGPoint {
|
||||
let point = CGPoint(x: 0.0, y: self.previousVelocity)
|
||||
return self.view?.convert(point, to: view) ?? .zero
|
||||
}
|
||||
|
||||
override public func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent) {
|
||||
super.touchesBegan(touches, with: event)
|
||||
|
||||
@@ -68,9 +74,12 @@ public final class WindowPanRecognizer: UIGestureRecognizer {
|
||||
override public func touchesEnded(_ touches: Set<UITouch>, with event: UIEvent) {
|
||||
super.touchesEnded(touches, with: event)
|
||||
|
||||
self.state = .ended
|
||||
|
||||
if let touch = touches.first {
|
||||
let location = touch.location(in: self.view)
|
||||
self.addPoint(location)
|
||||
self.previousVelocity = self.estimateVerticalVelocity()
|
||||
self.ended?(location, CGPoint(x: 0.0, y: self.estimateVerticalVelocity()))
|
||||
}
|
||||
}
|
||||
@@ -78,6 +87,8 @@ public final class WindowPanRecognizer: UIGestureRecognizer {
|
||||
override public func touchesCancelled(_ touches: Set<UITouch>, with event: UIEvent) {
|
||||
super.touchesCancelled(touches, with: event)
|
||||
|
||||
self.state = .cancelled
|
||||
|
||||
if let touch = touches.first {
|
||||
self.ended?(touch.location(in: self.view), nil)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user