|
|
@ -111,20 +111,19 @@ exports.nostack = function(items, margin, subgroups) { |
|
|
|
* @param {{horizontal: number, vertical: number}} margin |
|
|
|
* An object containing a horizontal and vertical |
|
|
|
* minimum required margin. |
|
|
|
* @param {boolean} rtl |
|
|
|
* @return {boolean} true if a and b collide, else false |
|
|
|
*/ |
|
|
|
exports.collision = function(a, b, margin, rtl) { |
|
|
|
var isCollision = null; |
|
|
|
if (rtl) { |
|
|
|
isCollision = ((a.right - margin.horizontal + EPSILON) < (b.right + b.width) && |
|
|
|
return ((a.right - margin.horizontal + EPSILON) < (b.right + b.width) && |
|
|
|
(a.right + a.width + margin.horizontal - EPSILON) > b.right && |
|
|
|
(a.top - margin.vertical + EPSILON) < (b.top + b.height) && |
|
|
|
(a.top + a.height + margin.vertical - EPSILON) > b.top); |
|
|
|
} else { |
|
|
|
((a.left - margin.horizontal + EPSILON) < (b.left + b.width) && |
|
|
|
return ((a.left - margin.horizontal + EPSILON) < (b.left + b.width) && |
|
|
|
(a.left + a.width + margin.horizontal - EPSILON) > b.left && |
|
|
|
(a.top - margin.vertical + EPSILON) < (b.top + b.height) && |
|
|
|
(a.top + a.height + margin.vertical - EPSILON) > b.top); |
|
|
|
} |
|
|
|
return isCollision; |
|
|
|
}; |