We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
function checkShow($node) { var scrollTop = $(window).scrollTop(); var windowHeight = $(window).height(); var offsetTop = $node.offset().top; if (offsetTop < scrollTop + windowHeight && offsetTop > scrollTop) { return true; } return false; }
$(window).on('scroll', function() { var scrollTop = $(window).scrollTop(); var windowHeight = $(window).height(); var offsetTop = $node.offset().top; if (offsetTop < scrollTop + windowHeight && offsetTop > scrollTop) { console.log(true); } });
$(window).on('scroll', function() { var scrollTop = $(window).scrollTop(); var windowHeight = $(window).height(); var offsetTop = $node.offset().top; if (offsetTop < scrollTop + windowHeight && offsetTop > scrollTop) { if ($node.attr('is-loaded')) { console.log(true); // 为元素添加一个自定义属性, 第一次出现时更改该属性. 这样就不会多次输出true $node.addClass('is-loaded'); } } });
查看源码:点击查看 效果预览:点击查看
The text was updated successfully, but these errors were encountered:
No branches or pull requests
题目1:如何判断一个元素是否出现在窗口可视范围(浏览器的上边缘和下边缘之间,肉眼可视)。
题目2:当窗口滚动时,判断一个元素是不是出现在窗口可视范围。每次出现都在控制台打印 true 。用代码实现
题目3:当窗口滚动时,判断一个元素是不是出现在窗口可视范围。在元素第一次出现时在控制台打印 true,以后再次出现不做任何处理。用代码实现
题目4: 图片懒加载的原理是什么?
题目5: 实现视频中的图片懒加载效果
查看源码:点击查看
效果预览:点击查看
The text was updated successfully, but these errors were encountered: