Created
February 25, 2012 07:49
-
-
Save s-hiroshi/1907275 to your computer and use it in GitHub Desktop.
jQuery > calculate offset
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 getOffset(inner, outer) { | |
// オフセット | |
var offsetX = Math.ceil(($(outer).width() - $(inner).width()) / 2); | |
var offsetY = Math.ceil(($(outer).height - $(inner).height()) / 2); | |
var offset = { | |
x: offsetX, | |
y: offsetY | |
}; | |
return offset; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment