1

I have been developing some jquery with sticky headers but when i test it on ipad there is a slight delay and jumps around the page.

is this an issue that can be solved in the code or is it a general ios problem? I have looked into the similar problems on the net but havent found a definite answer.

http://jsfiddle.net/47rYp/

var offset = $(".sticky-header").offset();
var sticky = document.getElementById("sticky-header")
var additionalPixels = 50;

$(window).scroll(function () {
    if ($(window).scrollTop() > offset.top - additionalPixels) {
        $('#profile-container').addClass('fixed');
    } else {
        $('#profile-container').removeClass('fixed');
    }
});

Thanks for any help !

user2965875
  • 701
  • 5
  • 11
  • 19

1 Answers1

3

The problem is that on an iPad the $(window).scroll does not continuously spawn. It only spawns once when you stop scrolling. As far as I know you cannot solve this.

Bas van Dijk
  • 9,933
  • 10
  • 55
  • 91
  • So your saving you cant have jquery elements for ipad? is there a way you can disable jquery on the ipad? – user2965875 Dec 02 '13 at 11:05
  • No you can definitely use jQuery elements. The problem is the scroll event binding does not trigger on scroll movement. It only triggers when you stopped scrolling. So your check if ($(window).scrollTop() > offset.top - additionalPixels) is only fired when you stopped scrolling and not continuously. – Bas van Dijk Dec 02 '13 at 11:58
  • How can I make this continuously? thanks for the help by the way ! – user2965875 Dec 02 '13 at 12:07
  • As far as I know, there is no way to fix this on iPad. – Bas van Dijk Dec 02 '13 at 12:11
  • I have found this solution which might help: http://stackoverflow.com/questions/2863547/javascript-scroll-event-for-iphone-ipad/17195346#17195346 – Bas van Dijk Dec 02 '13 at 12:13