Javascript 是否在滚动到特定位置后隐藏固定内容?

Javascript 是否在滚动到特定位置后隐藏固定内容?,javascript,css,wordpress,css-float,jquery-events,Javascript,Css,Wordpress,Css Float,Jquery Events,我使用这个()Javascript在我的站点上创建了社交共享栏。它的工作很好,但我不想显示它时,它是滚动到页面的页脚。如何做到这一点?这是我网站的一个页面,非常直接,因为您已经包含了jQuery: $(window).scroll(function() { //when scrolled var flt = $(".floater"); var offset = flt.offset().top + flt.height(); //get the current offset o

我使用这个()Javascript在我的站点上创建了社交共享栏。它的工作很好,但我不想显示它时,它是滚动到页面的页脚。如何做到这一点?这是我网站的一个页面,非常直接,因为您已经包含了jQuery:

$(window).scroll(function() { //when scrolled
    var flt = $(".floater");
    var offset = flt.offset().top + flt.height(); //get the current offset of the floater
    var footertop = $("#footer").offset().top; //and the footer's top offset
    if(offset > footertop) { //if you scrolled past the footer
        flt.hide(); //hide the sharing tab
    }
    else {
        flt.show(); //show it
    }
});

他可能想将
浮动框的高度添加到窗口的y偏移中。事实上,最好是找到
浮动框的偏移,而不是窗口的y偏移,因为它将包括任何其他定位(边距等)。