Skip to content

Instantly share code, notes, and snippets.

@Craga89
Created November 3, 2010 22:35
Show Gist options
  • Save Craga89/661839 to your computer and use it in GitHub Desktop.
Save Craga89/661839 to your computer and use it in GitHub Desktop.
Fixes the jQuery.offset() function for use with Mobile Safari browsers such as iPad, iPhone and iPod Touch
if( parseFloat(((/CPU.+OS ([0-9_]{3}).*AppleWebkit.*Mobile/i.exec(val)) || [0,'4_2'])[1].replace('_','.')) < 4.1) {
$.fn.Oldoffset = $.fn.offset;
$.fn.offset = function() {
var result = $(this).Oldoffset();
result.top -= window.scrollY;
result.left -= window.scrollX;
return result;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment