You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
session-ios/SignalMessaging/Views/ImageEditor/ImageEditorPanGestureRecogn...

37 lines
919 B
Swift

//
// Copyright (c) 2019 Open Whisper Systems. All rights reserved.
//
import UIKit
// This GR:
//
// * Tries to fail quickly to avoid conflicts with other GRs, especially pans/swipes.
// * Captures a bunch of useful "pan state" that makes using this GR much easier
// than UIPanGestureRecognizer.
public class ImageEditorPanGestureRecognizer: UIPanGestureRecognizer {
public weak var referenceView: UIView?
public var locationStart: CGPoint?
// MARK: - Touch Handling
@objc
public override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent) {
super.touchesBegan(touches, with: event)
guard let referenceView = referenceView else {
owsFailDebug("Missing view")
return
}
locationStart = self.location(in: referenceView)
}
public override func reset() {
super.reset()
locationStart = nil
}
}