Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save jasonweng/1581331 to your computer and use it in GitHub Desktop.

Select an option

Save jasonweng/1581331 to your computer and use it in GitHub Desktop.

Revisions

  1. @mataspetrikas mataspetrikas created this gist Jun 9, 2010.
    14 changes: 14 additions & 0 deletions fix jQuery.offset() in Mobile Safari (iPad, iPhone)
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,14 @@
    // 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);
    }