Skip to content

Instantly share code, notes, and snippets.

@kyo-ago
Created September 22, 2010 08:55
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 kyo-ago/591381 to your computer and use it in GitHub Desktop.
Save kyo-ago/591381 to your computer and use it in GitHub Desktop.
getScrollTop, getScrollLeftの設定
/**
* getScrollTop, getScrollLeftの設定
* @returns scroll position
*/
$.each([['Top', 'Y'], ['Left', 'X']], function () {
var name = this;
$[('getScroll' + name[0])] = function () {
var b = document.body['scroll' + name[0]] || 0;
var e = document.documentElement['scroll' + name[0]] || 0;
var s = window['scroll' + name[1]] || 0;
var p = window['page' + name[1] + 'Offset'] || 0;
return Math.max(b, e, s, p, 0);
};
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment