Permalink
Browse files

Better tracking

Making use of bounds instead of frame.
Making use of UIWindow rootViewController view to keep tracking of
absolute location.
  • Loading branch information...
1 parent e0b0333 commit 3d5cda279b33d1ccf2a4a348857dad481012db0e @nhisyam nhisyam committed Jun 10, 2013
Showing with 3 additions and 2 deletions.
  1. +3 −2 Library/DroppableView/JDDroppableView.m
@@ -153,9 +153,10 @@ - (void)dragAtPosition:(UITouch*)touch;
// check target contact
if (self.dropTargets.count > 0) {
+ UIView *rootView = [UIApplication sharedApplication].keyWindow.rootViewController.view;
+ CGRect viewRectInWindow = [self convertRect:self.bounds toView:rootView];
for (UIView *dropTarget in self.dropTargets) {
- CGRect viewRectInWindow = [self convertRect:self.frame toView:nil];
- CGRect dropTargetRectInWindow = [dropTarget convertRect:dropTarget.frame toView:nil];
+ CGRect dropTargetRectInWindow = [dropTarget convertRect:dropTarget.bounds toView:rootView];
CGRect intersect = CGRectIntersection(viewRectInWindow, dropTargetRectInWindow);
BOOL didHitTarget = intersect.size.width > 10 || intersect.size.height > 10;

0 comments on commit 3d5cda2

Please sign in to comment.