Skip to content

Commit

Permalink
Merge pull request #124 from Remigius2011/master
Browse files Browse the repository at this point in the history
fix scrolled drop target problem
  • Loading branch information
fatlinesofcode committed Apr 17, 2015
2 parents 8634fef + d25ff17 commit b378053
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions ngDraggable.js
Original file line number Diff line number Diff line change
Expand Up @@ -343,10 +343,8 @@ angular.module("ngDraggable", [])

var hitTest = function(x, y) {
var bounds = element[0].getBoundingClientRect();// ngDraggable.getPrivOffset(element);
bounds.right = bounds.left + element[0].offsetWidth - $window.pageXOffset;
bounds.bottom = bounds.top + element[0].offsetHeight - $window.pageYOffset;
x -= $window.pageXOffset;
y -= $window.pageYOffset;
x -= $document.body.scrollLeft + $document.documentElement.scrollLeft;
y -= $document.body.scrollTop + $document.documentElement.scrollTop;
return x >= bounds.left
&& x <= bounds.right
&& y <= bounds.bottom
Expand Down

2 comments on commit b378053

@adamkosmala
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, this causes issues with angular 1.3.15, as '$document is not defined'. Adding $document as dependency of directive ngDrop and replacing
$document.body with $document[0].body and $document.documentElement with $document[0].documentElementfixed issue for me

@lucas-garcia
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also getting $document is not defined.

Please sign in to comment.