Skip to content

Instantly share code, notes, and snippets.

@s-hiroshi
Created September 30, 2015 05:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save s-hiroshi/f557e3e4aa2e53558cd3 to your computer and use it in GitHub Desktop.
Save s-hiroshi/f557e3e4aa2e53558cd3 to your computer and use it in GitHub Desktop.
/**
* オフセット設定
*
* @method
* @private
* @param {jQuery} elem オフセットを設定する要素です。
* @param {Object} initial 要素の初期の大きさです。
* @param {Int} initial.width 初期の幅です。
* @param {Int} initial.height 初期の高さです。
* @returns {Function}
*/
function setOffset( elem, initial ) {
return function () {
elem.css( {
"left": (initial.width - elem.width()) / 2,
"top": (initial.height - elem.height() ) / 2
} );
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment