mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-24 07:05:35 +00:00
Check idea from be6bc8845d
This commit is contained in:
@@ -62,7 +62,18 @@ private func cancelOtherGestures(gesture: ContextGesture, view: UIView) {
|
||||
}
|
||||
}
|
||||
|
||||
private final class InternalGestureRecognizerDelegate: NSObject, UIGestureRecognizerDelegate {
|
||||
func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldRecognizeSimultaneouslyWith otherGestureRecognizer: UIGestureRecognizer) -> Bool {
|
||||
if otherGestureRecognizer is UIPanGestureRecognizer {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
public final class ContextGesture: UIGestureRecognizer, UIGestureRecognizerDelegate {
|
||||
private let internalDelegate = InternalGestureRecognizerDelegate()
|
||||
|
||||
public var beginDelay: Double = 0.12
|
||||
public var activateOnTap: Bool = false
|
||||
private var currentProgress: CGFloat = 0.0
|
||||
@@ -82,7 +93,7 @@ public final class ContextGesture: UIGestureRecognizer, UIGestureRecognizerDeleg
|
||||
override public init(target: Any?, action: Selector?) {
|
||||
super.init(target: target, action: action)
|
||||
|
||||
self.delegate = self
|
||||
self.delegate = self.internalDelegate
|
||||
}
|
||||
|
||||
override public func reset() {
|
||||
@@ -101,13 +112,6 @@ public final class ContextGesture: UIGestureRecognizer, UIGestureRecognizerDeleg
|
||||
self.wasActivated = false
|
||||
}
|
||||
|
||||
public func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldRecognizeSimultaneouslyWith otherGestureRecognizer: UIGestureRecognizer) -> Bool {
|
||||
if otherGestureRecognizer is UIPanGestureRecognizer {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
override public func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent) {
|
||||
super.touchesBegan(touches, with: event)
|
||||
|
||||
|
||||
@@ -72,7 +72,18 @@ public enum TapLongTapOrDoubleTapGestureRecognizerAction {
|
||||
case keepWithSingleTap
|
||||
}
|
||||
|
||||
private final class InternalGestureRecognizerDelegate: NSObject, UIGestureRecognizerDelegate {
|
||||
func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldRecognizeSimultaneouslyWith otherGestureRecognizer: UIGestureRecognizer) -> Bool {
|
||||
if otherGestureRecognizer is UIPanGestureRecognizer {
|
||||
return false
|
||||
}
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
public final class TapLongTapOrDoubleTapGestureRecognizer: UIGestureRecognizer, UIGestureRecognizerDelegate {
|
||||
private let internalDelegate = InternalGestureRecognizerDelegate()
|
||||
|
||||
private var touchLocationAndTimestamp: (CGPoint, Double)?
|
||||
private var touchCount: Int = 0
|
||||
private var tapCount: Int = 0
|
||||
@@ -96,14 +107,7 @@ public final class TapLongTapOrDoubleTapGestureRecognizer: UIGestureRecognizer,
|
||||
override public init(target: Any?, action: Selector?) {
|
||||
super.init(target: target, action: action)
|
||||
|
||||
self.delegate = self
|
||||
}
|
||||
|
||||
public func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldRecognizeSimultaneouslyWith otherGestureRecognizer: UIGestureRecognizer) -> Bool {
|
||||
if otherGestureRecognizer is UIPanGestureRecognizer {
|
||||
return false
|
||||
}
|
||||
return false
|
||||
self.delegate = self.internalDelegate
|
||||
}
|
||||
|
||||
override public func reset() {
|
||||
|
||||
Reference in New Issue
Block a user