ra1028 / RAReorderableLayout

A UICollectionView layout whitch can move item with drag and drop.
MIT License
867 stars 140 forks source link

Set any value in 'minimumPressDuration' of UILongPressGestureRecognizer #55

Open t-kitamura opened 7 years ago

t-kitamura commented 7 years ago

Hello ,

I want to set any value in 'minimumPressDuration' of UILongPressGestureRecognizer. But, I do not have a better idea.

Can you add this feature?

abhisheksingh1 commented 7 years ago
 // gesture recognizers
fileprivate func setUpGestureRecognizers() {
    guard let collectionView = collectionView else { return }
    guard longPress == nil && panGesture == nil else {return }
    longPress = UILongPressGestureRecognizer(target: self, action: #selector(RAReorderableLayout.handleLongPress(_:)))

    self.longPress?.minimumPressDuration = 0.001

    panGesture = UIPanGestureRecognizer(target: self, action: #selector(RAReorderableLayout.handlePanGesture(_:)))
    longPress?.delegate = self
    panGesture?.delegate = self
    panGesture?.maximumNumberOfTouches = 1
    let gestures: NSArray! = collectionView.gestureRecognizers as NSArray!
    gestures.enumerateObjects(options: []) { gestureRecognizer, index, finish in
        if gestureRecognizer is UILongPressGestureRecognizer {
            (gestureRecognizer as AnyObject).require(toFail: self.longPress!)
        }
        collectionView.addGestureRecognizer(self.longPress!)
        collectionView.addGestureRecognizer(self.panGesture!)
        }
    }

open func cancelDrag() {
    cancelDrag(nil)
}
ThuggishNuggets commented 7 years ago

Yeah, this really should be configurable.