我刚刚浏览了circliful的代码并遇到了以下几行代码:
function isElementInViewport() {
// Get the scroll position of the page.
var scrollElem = ((navigator.userAgent.toLowerCase().indexOf('webkit') != -1) ? 'body' : 'html');
var viewportTop = $(scrollElem).scrollTop();
var viewportBottom = viewportTop + $(window).height();
// Get the position of the element on the page.
var elemTop = Math.round(circle.offset().top);
var elemBottom = elemTop + circle.height();
return ((elemTop < viewportBottom) && (elemBottom > viewportTop));
}
现在我的问题是关于这一行代码:
var scrollElem = ((navigator.userAgent.toLowerCase().indexOf('webkit') != -1) ? 'body' : 'html');
为什么webkit浏览器的scrollTop()值应该是html
元素?