Created
June 1, 2018 03:53
-
-
Save jamesplease/de2b863dbffc0b1fa02a5edf870d710d to your computer and use it in GitHub Desktop.
This file contains hidden or 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 adjustedBoundingBox(boundingBox) { | |
const overflowTop = Math.min(boundingBox.top, 0); | |
const overflowLeft = Math.min(boundingBox.left, 0); | |
const overflowRight = Math.min(window.innerWidth - boundingBox.right, 0); | |
const overflowBottom = Math.min(window.innerHeight - boundingBox.bottom, 0); | |
return { | |
top: Math.max(boundingBox.top, 0), | |
left: Math.max(boundingBox.left, 0), | |
height: boundingBox.height + overflowTop + overflowBottom, | |
width: boundingBox.width + overflowLeft + overflowRight | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment