Skip to content

Commit 7ffbe13

Browse files
author
Michael Michailidis
committed
Simplified canDragAtPoint method
1 parent 97074fb commit 7ffbe13

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
.DS_Store
2-
2+
DerivedData/
3+
**/xcuserdata/**

KDDragAndDropCollectionViews/KDDragAndDropCollectionView.swift

+3-3
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,11 @@ class KDDragAndDropCollectionView: UICollectionView, KDDraggable, KDDroppable {
4646
// MARK : KDDraggable
4747
func canDragAtPoint(_ point : CGPoint) -> Bool {
4848

49-
guard let _ = self.dataSource as? KDDragAndDropCollectionViewDataSource else {
50-
return false
49+
if self.dataSource is KDDragAndDropCollectionViewDataSource {
50+
return self.indexPathForItem(at: point) != nil
5151
}
52+
return false
5253

53-
return self.indexPathForItem(at: point) != nil
5454
}
5555

5656
func representationImageAtPoint(_ point : CGPoint) -> UIView? {

KDDragAndDropCollectionViews/KDDragAndDropManager.swift

+3-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
import UIKit
1010

11+
12+
1113
@objc protocol KDDraggable {
1214
func canDragAtPoint(_ point : CGPoint) -> Bool
1315
func representationImageAtPoint(_ point : CGPoint) -> UIView?
@@ -129,7 +131,7 @@ class KDDragAndDropManager: NSObject, UIGestureRecognizerDelegate {
129131

130132
var mainOverView : UIView?
131133

132-
for view in self.views.filter({ v -> Bool in v is KDDroppable }) {
134+
for view in self.views where view is KDDraggable {
133135

134136
let viewFrameOnCanvas = self.convertRectToCanvas(view.frame, fromView: view)
135137

0 commit comments

Comments
 (0)