Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get scrollTop() while scrolling on iPad/iPhone

I'm trying to get the scrollTop() value while scrolling a website on the iPad/iPhone.

$(window).scroll(function(){
    console.log($(window).scrollTop());
});

I'm using this code for normal desktop browsers. On Safari with the Mac the console shows every pixel while scrolling. But on the iPad, I only get the value when the scrolling stops.

How can I get every scrollTop value while scrolling even on the iPad?

like image 826
Slevin Avatar asked May 16 '13 17:05

Slevin


2 Answers

Have you tried the following?

$(document).on( 'scroll', function(){
  var currentPosition = $(window).scrollTop();
  console.log(currentPosition);
});
like image 101
iPzard Avatar answered Sep 29 '22 09:09

iPzard


This limitation changed in iOS 8

This continues to log $(window).scrollTop() after touchend while the inertia/bounce effect is running:

$(document).on( 'scroll', function(){
console.log($(window).scrollTop());});

tested on iPad 9.2, iPhone 9.3.4

like image 20
Claytronicon Avatar answered Sep 29 '22 07:09

Claytronicon