Created
February 28, 2011 04:49
-
-
Save frangio/846950 to your computer and use it in GitHub Desktop.
a jquery method to get the position of an object relative to the viewport (doesn't work that well sometimes, because of merged margins and such)
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($) { | |
$.fn.viewportPosition = function() { | |
var a = this, b = a.offset().top - $(window).scrollTop(), c = a.offset().left - $(window).scrollLeft(); | |
return {top: b, left: c}; | |
}; | |
})(jQuery); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment