![](/img/trans.png)
[英]How can I display an image as a menu item once the user has scrolled down the page 150px?
[英]How do I check if a user has scrolled down 25%, 50%etc
我正在查看用户何时到达页面下方的某个 position。 所以我想在用户滚动 25%、50%、75% 并到达末尾时记录。
但是我不想在他们超过 x % 时记录,只要他们达到它。
window.addEventListener('scroll', function(e) {
var height = document.body.offsetHeight;
if(window.scrollY = (height * 0.25)) {
console.log('25%');
} else if(window.scrollY = (height * 0.50)) {
console.log('50%');
} else if(window.scrollY = (height * 0.75)) {
console.log('75%');
} else if(window.scrollY >= (height)) {
console.log('100%, reached the end');
};
});
我正在查看用户何时到达页面下方的某个 position。 所以我想在用户滚动 25%、50%、75% 并到达末尾时记录。
但是我不想在他们超过 x % 时记录,只要他们达到它。
window.addEventListener('scroll', function(e) {
var height = document.body.offsetHeight;
if(window.scrollY = (height * 0.25)) {
console.log('25%');
} else if(window.scrollY = (height * 0.50)) {
console.log('50%');
} else if(window.scrollY = (height * 0.75)) {
console.log('75%');
} else if(window.scrollY >= (height)) {
console.log('100%, reached the end');
};
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.