Created
November 2, 2016 22:37
-
-
Save m-arrieta-r/a277fc2a9b1e860572bebd65fc1061f6 to your computer and use it in GitHub Desktop.
isItOverflow
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
var getTotalMarginSize = function (element) { | |
var ml = parseInt(window.getComputedStyle(element).marginLeft); | |
var mr = parseInt(window.getComputedStyle(element).marginLeft); | |
return ml+mr; | |
}; | |
var getChildrenSize = function(container) { | |
var children = container.children; | |
var sizeCounter = 0; | |
for(var i = 0; i < children.length; i++) { | |
var element = children[i]; | |
sizeCounter += element.offsetWidth; | |
sizeCounter += getTotalMarginSize(element); | |
} | |
return sizeCounter; | |
}; | |
var isItOverflow = function (container) { | |
var childrenSize = getChildrenSize(container); | |
return (container.offsetWidth > childrenSize); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment