Skip to content

Instantly share code, notes, and snippets.

@rty
Created June 11, 2010 06:56
Show Gist options
  • Save rty/434145 to your computer and use it in GitHub Desktop.
Save rty/434145 to your computer and use it in GitHub Desktop.
// small fix for old safari versions compatibility
// this bug occures
// on iPhone OS since 3.2 version (iPad)
// and on iOS since 4.0 version
// as of 1.4.2 the mobile safari reports wrong values on offset()
// http://dev.jquery.com/ticket/6446
// remove once it's fixed
if (/webkit.*mobile/i.test(navigator.userAgent)
&& "getBoundingClientRect" in document.documentElement) {
(function ($) {
$.fn.offsetOld = $.fn.offset;
$.fn.offset = function () {
var result = this.offsetOld();
result.top -= window.scrollY;
result.left -= window.scrollX;
return result;
};
})(jQuery);
}
@rty
Copy link
Author

rty commented Oct 8, 2010

Yeah! It's cool solution:)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment