Permalink
Browse files

fixed horrible bug, added new intersection type 'portion': returns th…

…e the percentage of overlapping area as float 0-1
  • Loading branch information...
1 parent 26502d3 commit f8847670d7535c6134717117572c414b416fe50b @Mtillmann committed Aug 25, 2011
Showing with 3 additions and 4 deletions.
  1. +3 −4 jquery-rect.js
View
@@ -32,7 +32,7 @@
var toRect = function( box ){
return {
left : box.left,
- top : box.left,
+ top : box.top,
width : box.right - box.left,
height: box.bottom - box.top
};
@@ -101,15 +101,15 @@
return false;
}
- plugin.intersection = function( el, type ){
+ plugin.intersection = function( el, type, positionParent ){
var boxes = plugin.intersects( el, true );
if(!boxes)return false;
var a = boxes[0], b = boxes[1],
x0 = Math.max(a.left, b.left),
x1 = Math.min(a.right, b.right),
- y0, y1, iRect;
+ y0, y1, iBox;
if (x0 <= x1) {
y0 = Math.max(a.top, b.top);
@@ -131,7 +131,6 @@
var areaA = getArea( a ),
areaB = getArea(toRect( iBox ));
return areaB / areaA;
- //return Math.min( areaA, areaB ) / Math.max( areaA, areaB);
}
return toRect( iBox );

0 comments on commit f884767

Please sign in to comment.