1

I just implement an infinite scroll without plugins in JavaScript with jQuery but it doesn't work on mobile browser. Works fine on computer browser..

$(window).scroll(function(event) {
    if ($(window).scrollTop() + $(window).height() == $(document).height()) {
          alert('bottom');
    }
}

I just want to load content when the scroll reaches the bottom. It doesn't work on iPhone, iPad and Nexus 5 browser. What can be the problem?

Weinz
  • 396
  • 1
  • 5
  • 23
  • 1
    What do `$(window).scrollTop()`, `$(window).height()` and `$(document).height()` return when you reach the bottom? – Cthulhu Jun 04 '14 at 16:37
  • On desktop version 1042,867,1909 . But on mobile never enters the if condition – Weinz Jun 04 '14 at 16:42
  • And on the iPhone, iPad and Nexus 5 browsers what are the values then scrolling (visually) at the bottom? – Cthulhu Jun 04 '14 at 16:44
  • Then it is probably horizontal scroll bar not taken into account... Try to use this [http://stackoverflow.com/a/10795797/2195721] solution. – Cthulhu Jun 04 '14 at 16:52
  • `scrollTop` is flaky on mobile devices — further compounded by rubber-banding and the way events are generated. You could try `offset().top` instead. – Foreign Object Jun 04 '14 at 16:54
  • What do i use $(document).offset().top ? – Weinz Jun 05 '14 at 17:33

0 Answers0