Created
August 31, 2018 14:15
-
-
Save adrixvoid/f3f5d615ad470f3c86dcb628815e5680 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
getChildOffset = (item, isVertical) => { | |
isVertical = isVertical || false; | |
let nodeStyle = window.getComputedStyle(item); | |
if (isVertical) { | |
let marginTop = parseInt(nodeStyle.getPropertyValue('margin-top'), 10); | |
let marginBottom = parseInt(nodeStyle.getPropertyValue('margin-bottom'), 10); | |
return marginTop + marginBottom; | |
} else { | |
let marginRight = parseInt(nodeStyle.getPropertyValue('margin-right'), 10); | |
let marginLeft = parseInt(nodeStyle.getPropertyValue('margin-left'), 10); | |
return marginRight + marginLeft; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment