简体   繁体   English

固定带有jQuery动画的标头滚动停止

[英]Fixed header on-scroll with jQuery animate with stop

After long search on google and everywhere I couldnt find a solution to my problem. 在Google上和所有地方进行长时间搜索后,我找不到解决我问题的方法。 I am developing a wordpress theme and having issue with my header on scrolling... On fast scrollbar scrolling the menu, logo, and header height does not return back to its state. 我正在开发wordpress主题,并且在滚动时出现标题问题...在快速滚动条上滚动菜单,徽标和标题高度不会返回到其状态。

How i can fix that??? 我该如何解决???

i am using this code: 我正在使用此代码:

jQuery(function(){
    jQuery('.header-v4').data('size','big');

    });

    if(jQuery(".header-v4.header-1").length > 0){
    var ot = jQuery(".header-v4.header-1").offset().top;
    var head_height = jQuery(".header-v4").height();
    }


jQuery(window).scroll(function(){

         var sticky = jQuery('.header-v4.header-1,.header-v4.header-2');            

                if(sticky.length > 0){
                    if(jQuery(document).scrollTop() > ot){
                        sticky.addClass('fixed');
                        jQuery('.band.blog,#slider_holder').css('marginTop',head_height);
                    }else{
                        sticky.removeClass('fixed');
                        jQuery('.band.blog,#slider_holder').css('marginTop',0);
                    }
                }



                if(jQuery(document).scrollTop() > 200){

                    if(jQuery('.header-v4').data('size') == 'big')
                    {
                        jQuery('.header-v4').data('size','small');

                        //Header-1
                        jQuery('.header-1 img.logo').stop().animate({width:'80%'},'fast');
                        jQuery('.header-1 .logo_vertical_align').stop().animate({marginTop:'15px'},'fast');
                        jQuery('.header-1 .navigation').stop().animate({marginBottom:'15px'},'fast');
                        jQuery('.header-1 .nav-header-v4').stop().animate({height:'0px'},'fast');
                        jQuery('.header-v4.header-1').stop().animate({height:'60px'},'fast');

                    }


                }else{

                        if(jQuery('.header-v4.fixed').data('size') == 'small')
                    {
                        jQuery('.header-v4.fixed').data('size','big');

                        //Header-1
                        jQuery('.header-1 img.logo').stop().animate({width:'100%'},'fast');
                        jQuery('.header-1 .logo_vertical_align').stop().animate({marginTop:'30px'},'fast');
                        jQuery('.header-1 .navigation').stop().animate({marginBottom:'0px'},'fast');
                        jQuery('.header-1 .nav-header-v4').stop().animate({height:'96px'},'fast');
                        jQuery('.header-v4.header-1.fixed').stop().animate({height:head_height},'fast')


                    }  
            }
    });

Really appreciate your support 非常感谢您的支持

the initial code was taken from this post : https://stackoverflow.com/a/16442479 最初的代码是从这篇文章中获取的: https : //stackoverflow.com/a/16442479

you can test the issue on this url : http://expobizxml.janxcode.com 您可以在以下网址上测试该问题: http : //expobizxml.janxcode.com

I noticed that when you scroll back up, the second stage of the top bar doesn't return to it's original size. 我注意到,当您向上滚动时,顶部栏的第二阶段不会恢复到其原始大小。

After scrolling and returning back to the second stage, class="band header-v4 header-1 fixed" height="81px" but it should be "96px" when you get to the second stage of the header. 滚动并返回到第二阶段后, class="band header-v4 header-1 fixed" height="81px"但是当您到达标题的第二阶段时,它应该为"96px"

Thanks for your contribution and for your time, i have fixed it by removing the fixed class name 感谢您的贡献和您的时间,我已通过删除固定的类名称来解决此问题

if(jQuery('.header-v4.fixed').data('size') == 'small')
                {
                    jQuery('.header-v4.fixed').data('size','big');

..... .....

FiSH GRAPHICS, thanks for your comment i will chk why it is like that FISH GRAPHICS,谢谢您的评论,我会查问为什么会这样

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM