You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// 判断元素是否在视口中functionisEleVisible(ele){var{top, right, bottom, left}=ele.getBoundingClientRect()varw=window.innerWidthvarh=window.innerHeightif(bottom<0||top>h){// y 轴方向returnfalse}if(right<0||left>w){// x 轴方向returnfalse}returntrue}
Activity
xujs0813 commentedon Jan 20, 2021
fanerge commentedon Jan 22, 2021
使用 IntersectionObserver 实现,性能更好
IntersectionObserver