The rect.left+window.pageXOffset+"px"
value is only Chrome for android different from other browsers.
IE11, FireFox, Chrome for windows, FireFox for android get the expected value.
You can't get the expected value only when you zoom in on Android and scroll.
Is this the chrome for Android specification?
Can you find something like the javascript specification for chrome for android online?
I don't know how to check it myself.Thank you for your cooperation.
On Android, the browser may return 0s for window.pageXOffset
or window.pageYOffset
.
I have a similar question in my home SO.
It is recommended that you temporarily save the acquired values
var cachedPosition;
window.addEventListener("scroll", function(){
varposition=window.pageYOffset;
console.log('position:'+position);
if(position===0){
position = cachedPosition;
} else{
cachedPosition=position;
}
console.log('cached position:'+cachedPosition);
}, false);
© 2024 OneMinuteCode. All rights reserved.