I don't know what's going on with this code.
$(document).ready(function()
{
$(window).on('scroll touchstart', function() {
console.log(
"$('body').scrollTop="+$('body').scrollTop()
+", $('html').scrollTop="+$('html').scrollTop()
+", window.scrollTop= "+$(window).scrollTop()
+", document.documentElement.scrollTop= "+document.documentElement.scrollTop
+", window.pageYOffset= "+window.pageYOffset
+", window.scrollY= "+window.scrollY
+", document.body.scrollTop= "+document.body.scrollTop
+", document.scrollingElement.scrollTop="+document.scrollingElement.scrollTop
);
});
});
All are always returning zero, until I've scrolled right down the bottom of the page. At that point, they return really low values. Like about 50 pixels or 100 pixels, when I've scrolled down easily 500-1000 pixels.
I thought it was due to this but I removed the height:100%
from my CSS for body and html, and I get the same problem. I've also tried adding body { height: auto !important; }
It's not happening on any browsers on my windows PC, (IE, Chrome, Firefox, Edge) but it is happening on all my browsers on Android. (Chrome, Samsung browser, Firefox, DuckDuckGo).
What's going on? Are there alternatives?
Thanks