Forked from mataspetrikas/fix jQuery.offset() in Mobile Safari (iPad, iPhone)
Created
January 9, 2012 05:38
-
-
Save jasonweng/1581331 to your computer and use it in GitHub Desktop.
fix jQuery.offset() in Mobile Safari (iPad, iPhone)
This file contains 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
// 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)) { | |
(function($) { | |
$.fn.offsetOld = $.fn.offset; | |
$.fn.offset = function() { | |
var result = this.offsetOld(); | |
result.top -= window.scrollY; | |
result.left -= window.scrollX; | |
return result; | |
}; | |
})(jQuery); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment