jQuery 浮动菜单在 Chrome 中不起作用
我正在为 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
I have a floating menu plugin I am working on for jQuery and its driving me crazy as it works fine in other browsers but in Chrome it just sits there instead of scrolling the page when the user scrolls up or down:
// 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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
试试这个:
Try this: