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