向下滚动jquery时向下滑动菜单

时间:2013-08-24 12:11:59

标签: jquery

我希望向上滚动时向下滚动,向上滚动时向上滑动。

http://jsfiddle.net/aP7JY/8/

//when scroll down top-bar is fixed
$(function() {
    var top = $("#top-bar");
    $(window).scroll(function() {    
        var scroll = $(window).scrollTop();

        if (scroll >= 170) {
            top.show("fast").addClass("fixed");
        } else {
            top.removeClass("fixed");
        }
    });
});

2 个答案:

答案 0 :(得分:0)

function JSFX_FloatBottomLeft() {

var startX = 40, startY = 100;
var ns = (navigator.appName.indexOf("Netscape") != -1);
var d = document;
function ml(id) {
    var el = d.getElementById ? d.getElementById(id) : d.all ? d.all[id] : d.layers[id];
    if (d.layers) el.style = el;
    el.sP = function(x, y) { this.style.left = x + "px"; this.style.top = y + "px"; };
    el.x = startX;
    el.y = ns ? pageYOffset + innerHeight : document.body.scrollTop + document.body.clientHeight;
    el.y -= startY;
    return el;
}
window.stayBottomLeft = function() {
    var pY = ns ? pageYOffset + innerHeight : document.body.scrollTop + document.body.clientHeight;

    fblObj.y += (pY - startY - fblObj.y) / 8;
    fblObj.sP(fblObj.x, fblObj.y);
    setTimeout("stayBottomLeft()", 40);
};
fblObj = ml("dvPlumbCamp");
stayBottomLeft();}

根据移动

将保持左下方缓慢滑动

答案 1 :(得分:0)

这可能会有所帮助。

   $(function() {
        var top = $("#top-bar");
        $(window).scroll(function() {    

            var scroll = $(window).scrollTop();
            $('#top-bar').offset({'top' : scroll});

        });
    });
相关问题