jQuery 浮动菜单在 Chrome 中不起作用

发布于 2024-10-30 18:28:55 字数 1265 浏览 5 评论 0原文

我正在为 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

_蜘蛛 2024-11-06 18:28:55

试试这个:

$("#fblb_cont").stop().animate({top: newPos + 'px'},
                          defaults.float_speed, float_easing);

Try this:

$("#fblb_cont").stop().animate({top: newPos + 'px'},
                          defaults.float_speed, float_easing);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文