Created
February 8, 2014 18:24
-
-
Save netgfx/8887894 to your computer and use it in GitHub Desktop.
Check max-min positions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function checkMaxMinPos(a, b, aW, aH, bW, bH, maxX, minX, maxY, minY) { | |
'use strict'; | |
if (a.left < b.left) { | |
if (a.left < minX) { | |
minX = a.left; | |
} | |
} else { | |
if (b.left < minX) { | |
minX = b.left; | |
} | |
} | |
if (a.left + aW > b.left + bW) { | |
if (a.left > maxX) { | |
maxX = a.left + aW; | |
} | |
} else { | |
if (b.left + bW > maxX) { | |
maxX = b.left + bW; | |
} | |
} | |
//////////////////////////////// | |
if (a.top < b.top) { | |
if (a.top < minY) { | |
minY = a.top; | |
} | |
} else { | |
if (b.top < minY) { | |
minY = b.top; | |
} | |
} | |
if (a.top + aH > b.top + bH) { | |
if (a.top > maxY) { | |
maxY = a.top + aH; | |
} | |
} else { | |
if (b.top + bH > maxY) { | |
maxY = b.top + bH; | |
} | |
} | |
return { | |
'maxX': maxX, | |
'minX': minX, | |
'maxY': maxY, | |
'minY': minY | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment