<commit_before>//
//  DirectedPanGestureRecognizer.swift
//  DirectedPanGestureRecognizer
//
//  Created by <NAME> on 5/03/16.
//  Copyright © 2016 <NAME>. All rights reserved.
//

import UIKit
import UIKit.UIGestureRecognizerSubclass

/// Extension of `UIGestureRecognizerDelegate` which allows the delegate to receive messages when the pan gesture recognizer starts, updates, cancels, and finishes. The `delegate` property can be set to a class implementing `DirectedPanGestureRecognizerDelegate` and it will receive these messages.
@objc public protocol DirectedPanGestureRecognizerDelegate: UIGestureRecognizerDelegate {
    
    /// Called when the pan gesture recognizer starts.
    optional func directedPanGestureRecognizerDidStart(gestureRecognizer: DirectedPanGestureRecognizer)
    
    /// Called when the pan gesture recognizer updates.
    optional func directedPanGestureRecognizerDidUpdate(gestureRecognizer: DirectedPanGestureRecognizer)
    
    /// Called when the pan gesture recognizer cancels. A pan gesture recognizer may cancel if its translation or velocity in `initialDirection` is less than the value of `minimumTranslation` or `minimumVelocity`, respectively.
    optional func directedPanGestureRecognizerDidCancel(gestureRecognizer: DirectedPanGestureRecognizer)
    
    /// Called when the pan gesture recognizer finishes. A pan gesture recognizer may finish if its translation and velocity in `initialDirection` are greater than or equal to the value of `minimumTranslation` or `minimumVelocity`, respectively.
    optional func directedPanGestureRecognizerDidFinish(gestureRecognizer: DirectedPanGestureRecognizer)
    
}

public class DirectedPanGestureRecognizer: UIPanGestureRecognizer {
    
    /// The pan gesture recognizer's direction. Also used to calculate attributes for a given direction.
    public enum Direction {
        /// The pan gesture recognizer's touches move upwards.
        case Up
        /// The pan gesture recognizer's touches move leftwards.
        case Left
        /// The pan gesture recognizer's touches move downwards.
        case Down
        /// The pan gesture recognizer's touches move rightwards.
        case Right
    }
    
    // MARK: Configuration
    
    /// Minimum translation (in `initialDirection`) required for the gesture to finish. Defaults to `0.0`.
    @IBInspectable public var minimumTranslation: CGFloat = 0.0
    
    /// Minimum velocity (in `initialDirection`) required for the gesture to finish. Defaults to `0.0`.
    @IBInspectable public var minimumVelocity: CGFloat = 0.0
    
    // MARK: Internal variables
    
    /// The current location in `view` when the pan gesture recognizer begins. Defaults to `nil`. Resets to `nil` when `reset()` is called.
    public private(set) var initialLocation: CGPoint?
    
    /// The current direction in `view` when the pan gesture recognizer begins. Defaults to `nil`. Resets to `nil` when `reset()` is called.
    public private(set) var initialDirection: Direction?
    
    // MARK: Delegation
    
    public override var delegate: UIGestureRecognizerDelegate? {
        didSet {
            self.addTarget(self, action: "onPan")
        }
    }
    
    internal var directedPanDelegate: DirectedPanGestureRecognizerDelegate? {
        return delegate as? DirectedPanGestureRecognizerDelegate
    }
    
    // MARK: Initialization
    
    /// Initialize the pan gesture recognizer with no target or action set.
    public convenience init() {
        self.init(target: nil, action: nil)
    }
    
    // MARK: Overrides
    
    public override func reset() {
        super.reset()
        
        initialLocation = nil
        initialDirection = nil
    }<commit_msg>Upgraded selectors to Swift 2.2 syntax<commit_after>//
//  DirectedPanGestureRecognizer.swift
//  DirectedPanGestureRecognizer
//
//  Created by <NAME> on 5/03/16.
//  Copyright © 2016 <NAME>. All rights reserved.
//

import UIKit
import UIKit.UIGestureRecognizerSubclass

/// Extension of `UIGestureRecognizerDelegate` which allows the delegate to receive messages when the pan gesture recognizer starts, updates, cancels, and finishes. The `delegate` property can be set to a class implementing `DirectedPanGestureRecognizerDelegate` and it will receive these messages.
@objc public protocol DirectedPanGestureRecognizerDelegate: UIGestureRecognizerDelegate {
    
    /// Called when the pan gesture recognizer starts.
    optional func directedPanGestureRecognizerDidStart(gestureRecognizer: DirectedPanGestureRecognizer)
    
    /// Called when the pan gesture recognizer updates.
    optional func directedPanGestureRecognizerDidUpdate(gestureRecognizer: DirectedPanGestureRecognizer)
    
    /// Called when the pan gesture recognizer cancels. A pan gesture recognizer may cancel if its translation or velocity in `initialDirection` is less than the value of `minimumTranslation` or `minimumVelocity`, respectively.
    optional func directedPanGestureRecognizerDidCancel(gestureRecognizer: DirectedPanGestureRecognizer)
    
    /// Called when the pan gesture recognizer finishes. A pan gesture recognizer may finish if its translation and velocity in `initialDirection` are greater than or equal to the value of `minimumTranslation` or `minimumVelocity`, respectively.
    optional func directedPanGestureRecognizerDidFinish(gestureRecognizer: DirectedPanGestureRecognizer)
    
}

public class DirectedPanGestureRecognizer: UIPanGestureRecognizer {
    
    /// The pan gesture recognizer's direction. Also used to calculate attributes for a given direction.
    public enum Direction {
        /// The pan gesture recognizer's touches move upwards.
        case Up
        /// The pan gesture recognizer's touches move leftwards.
        case Left
        /// The pan gesture recognizer's touches move downwards.
        case Down
        /// The pan gesture recognizer's touches move rightwards.
        case Right
    }
    
    // MARK: Configuration
    
    /// Minimum translation (in `initialDirection`) required for the gesture to finish. Defaults to `0.0`.
    @IBInspectable public var minimumTranslation: CGFloat = 0.0
    
    /// Minimum velocity (in `initialDirection`) required for the gesture to finish. Defaults to `0.0`.
    @IBInspectable public var minimumVelocity: CGFloat = 0.0
    
    // MARK: Internal variables
    
    /// The current location in `view` when the pan gesture recognizer begins. Defaults to `nil`. Resets to `nil` when `reset()` is called.
    public private(set) var initialLocation: CGPoint?
    
    /// The current direction in `view` when the pan gesture recognizer begins. Defaults to `nil`. Resets to `nil` when `reset()` is called.
    public private(set) var initialDirection: Direction?
    
    // MARK: Delegation
    
    public override var delegate: UIGestureRecognizerDelegate? {
        didSet {
            self.addTarget(self, action: #selector(onPan))
        }
    }
    
    internal var directedPanDelegate: DirectedPanGestureRecognizerDelegate? {
        return delegate as? DirectedPanGestureRecognizerDelegate
    }
    
    // MARK: Initialization
    
    /// Initialize the pan gesture recognizer with no target or action set.
    public convenience init() {
        self.init(target: nil, action: nil)
    }
    
    // MARK: Overrides
    
    public override func reset() {
        super.reset()
        
        initialLocation = nil
        initialDirection = nil
    }
{'fraction_non_alphanumeric': 0.06680919294494922, 'fraction_numerical': 0.004810261892036344, 'mean_word_length': 3.22165820642978, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5880130', 'n_tokens_mistral': 2040, 'n_tokens_neox': 1880, 'n_words': 717}