简体   繁体   English

jQuery lineheight行为很奇怪

[英]Jquery lineheight acts weird

I'm running this script, but when I scroll it runs all the functions at the same time, EXCEPT for the lineheight part. 我正在运行此脚本,但是当我滚动它时,它将同时运行所有功能,但lineheight部分除外。 It runs the lineheight part after all the others. 它在所有其他部分之后运行lineheight部分。 And it should run them all at the same time! 它应该同时运行它们!

Any suggestions? 有什么建议么?

Thank you! 谢谢!

$(function () {
    $('Header').data('size', 'big');
});

$(window).scroll(function () {
    if ($(document).scrollTop() > 1) {
        if ($('Header').data('size') == 'big') {
            $('Header').data('size', 'small');
            $('Header').stop().animate({
                height: '60px', opacity: '0.97'
            }, 300);
            $('Header a').stop().animate({
                height: '60px'
            }, 300);
            $('#headerFiller').stop().animate({
                height: '60px'
            }, 300);
            $('Header ul li').stop().animate({
                lineHeight: '60px'
            }, 300);

            $('#logo').stop().animate({
                marginTop: '-1px',
                height: '50px'
            }, 300);
        }
    }
    else {
        if ($('Header').data('size') == 'small') {
            $('Header').data('size', 'big');
            $('Header').stop().animate({
                height: '100px'
            }, 300);
            $('Header a').stop().animate({
                height: '100px'
            }, 300);
            $('#headerFiller').stop().animate({
                height: '100px'
            }, 300);
            $('#logo').stop().animate({
                marginTop: '0px',
                height: '85px'
            }, 300);
            $('Header ul li').stop().animate({
                lineHeight: '100px'
            }, 300);
        }
    }
});

I believe what you need is queue: false so all your effects run simultaneously (don't get place in a queue ). 我相信您需要的是queue: false因此所有效果都同时运行(不要放在queue )。 You can see more info in the documentation . 您可以在文档中查看更多信息。

 $('Header ul li').stop().animate({
    lineHeight: '100px'
 }, { duration: 300, queue: false});

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

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