小弟没看懂,画红线的这俩块是什么意思

        $(window).scroll(function() {
            if ($(window).scrollTop() >= $(".cent-line-box").offset().top - $(window).height()/2 + 5 && !$(".history-wrap .cent-wrap li").last().hasClass('show')) {
                $(".cent-line-box").addClass('active');
                $(".cent-line-box .point-h").show();
            }else{
                $(".cent-line-box").removeClass('active');
                $(".cent-line-box .point-h").hide();
            }

            $(".history-wrap .cent-wrap li").each(function() {
                var _this = $(this);
                if ($(window).scrollTop() >= $(this).offset().top - $(window).height() + 260) {
                    _this.addClass('show');
                }else{
                    _this.removeClass('show');
                }
            });
        });

clipboard.png

阅读 1.5k
1 个回答

第一个框,如果window的滚动条距离顶部的高度大于(.cent-line-box距离父元素的高度减去(window的高度除以2再加5)),并且.history-wrap .cent-wrap li最后一个li没有class show,则执行下面的代码。

第二个框,如果window的滚动条距离顶部的高度大于等于(.history-wrap .cent-wrap li距离父元素的高度减去window的高度再加260),那么久这个li加上show,否则remove .show

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题