我有一个浮动菜单插件我正在为jQuery工作,它让我发疯,因为它在其他浏览器中工作正常但在Chrome中它只是坐在那里而不是在用户向上或向下滚动时滚动页面:
// Cache :)
var fblb_cont = $("#fblb_cont");
var fblb_main = $("#fblb_cont .fblb_main");
var fblb_pos = $('#fblb_cont').position().top;
var float_easing = "easeOutQuint";
// When the user scrolls
$(window).scroll(function () {
// Float our bar to correct page location
// Figure out how much to scroll
var scroll_factor = $(document).scrollTop();
// Create our new scrollTo position
var newPos = ( fblb_pos + scroll_factor );
// Check if the window height is within bounds
if( $(window).height() < $("#fblb_cont").height()+$("#fblb_cont .fblb_main").height() ){
// Adjust where needed
fblb_cont.css("top", fblb_pos);
} else {
// Otherwise animate our scroll to the new position
$("#fblb_cont").stop().animate({top: newPos}, defaults.float_speed, float_easing);
} // End if
}); // End on scroll
答案 0 :(得分:0)
试试这个:
$("#fblb_cont").stop().animate({top: newPos + 'px'},
defaults.float_speed, float_easing);