Javascript 使用Jquery(建议)制作动画(随着时间的推移,条形图填充)

Javascript 使用Jquery(建议)制作动画(随着时间的推移,条形图填充),javascript,jquery,animation,Javascript,Jquery,Animation,我想复制与ign.com相同的功能,其中指示栏会随着时间的推移而填满。我让它工作,但我有一些同步问题后,一段时间。所以我愿意接受建议从头开始做(我是所有这些动画的初学者) 这是代码 function GoProgressBar() { var $lineStatus = $('.featured-articles-line-status'); $lineStatus.css('width', '0px'); $lineStatus.animate({ width: '

我想复制与
ign.com
相同的功能,其中指示栏会随着时间的推移而填满。我让它工作,但我有一些同步问题后,一段时间。所以我愿意接受建议从头开始做(我是所有这些动画的初学者)

这是代码

function GoProgressBar() {

    var $lineStatus = $('.featured-articles-line-status');

    $lineStatus.css('width', '0px');
    $lineStatus.animate({ width: '694px' }, 12000, 'linear', GoProgressBar);

};

function GoOverlay(width, isLast, currentWidth) {

    var $overlayLine = $('.status-overlay');

    if (isLast) {

        $overlayLine.css('width', '0px');
        return;
    }

    if (currentWidth) {

        $overlayLine.css('width', currentWidth);
        $overlayLine.animate({ width: width }, 700);
    } else {

        $overlayLine.css('width', '0px');
        $overlayLine.animate({ width: width }, 700);

    }

};


function ShowNextElement() {

    var $elements = $('.element'),
        $overlayLine = $('.status-overlay'),
        $liElements = $('#elements li'),
        width;

    if (currentElement === elements[elements.length - 1]) {

        currentWidth = $overlayLine.width() + 'px',
        width = currentWidth + $($liElements[(elements.length - 1)]).outerWidth() + 'px';

        GoOverlay(width, true, currentWidth);


        currentElement = elements[0];

        $elements.hide();
        $(currentElement).fadeIn(1000);
        return;
    }


    i = elements.indexOf(currentElement) + 1;

    var currentTab = $liElements[(i - 1)],
        currentWidth = $overlayLine.width();

    if (currentWidth) {

        width = currentWidth + $(currentTab).outerWidth() + 'px';
        GoOverlay(width, false, currentWidth);

    } else {
        width = $(currentTab).outerWidth() + 'px';

        GoOverlay(width, false, false);
    }

    currentElement = elements[i];
    $elements.hide();
    $(currentElement).fadeIn(1000);

}
谢谢

你可以试试这个

除此之外还有更多功能,请查看。 可能有用:)

你可以试试这个

除此之外还有更多功能,请查看。 可能有用:)

你可以试试这个

除此之外还有更多功能,请查看。 可能有用:)

你可以试试这个

除此之外还有更多功能,请查看。
可能有用:)

有很多方法可以做到这一点

您应该有某种控制器来管理显示和隐藏

var Application = {
    show : function() {
        jQuery('.application-overlay').stop().animate({ top: 40 }, 500);
        jQuery('.cf-ribbon').stop().animate({height: 1000},500);
    },
    hide : function() {
        jQuery('.application-overlay').stop().animate({ top: -1200 }, 500);
        jQuery('.cf-ribbon').stop().animate({height: 200},500);
    }
};
然后就有了触发器:
Application.show()

你的css当然也会发挥作用,但这可以留给你


这应该给你一个你需要的例子。。但是你已经走上了正确的道路,有时候重用别人的代码也是有好处的,你知道的!:)

有很多方法可以做到这一点

您应该有某种控制器来管理显示和隐藏

var Application = {
    show : function() {
        jQuery('.application-overlay').stop().animate({ top: 40 }, 500);
        jQuery('.cf-ribbon').stop().animate({height: 1000},500);
    },
    hide : function() {
        jQuery('.application-overlay').stop().animate({ top: -1200 }, 500);
        jQuery('.cf-ribbon').stop().animate({height: 200},500);
    }
};
然后就有了触发器:
Application.show()

你的css当然也会发挥作用,但这可以留给你


这应该给你一个你需要的例子。。但是你已经走上了正确的道路,有时候重用别人的代码也是有好处的,你知道的!:)

有很多方法可以做到这一点

您应该有某种控制器来管理显示和隐藏

var Application = {
    show : function() {
        jQuery('.application-overlay').stop().animate({ top: 40 }, 500);
        jQuery('.cf-ribbon').stop().animate({height: 1000},500);
    },
    hide : function() {
        jQuery('.application-overlay').stop().animate({ top: -1200 }, 500);
        jQuery('.cf-ribbon').stop().animate({height: 200},500);
    }
};
然后就有了触发器:
Application.show()

你的css当然也会发挥作用,但这可以留给你


这应该给你一个你需要的例子。。但是你已经走上了正确的道路,有时候重用别人的代码也是有好处的,你知道的!:)

有很多方法可以做到这一点

您应该有某种控制器来管理显示和隐藏

var Application = {
    show : function() {
        jQuery('.application-overlay').stop().animate({ top: 40 }, 500);
        jQuery('.cf-ribbon').stop().animate({height: 1000},500);
    },
    hide : function() {
        jQuery('.application-overlay').stop().animate({ top: -1200 }, 500);
        jQuery('.cf-ribbon').stop().animate({height: 200},500);
    }
};
然后就有了触发器:
Application.show()

你的css当然也会发挥作用,但这可以留给你


这应该给你一个你需要的例子。。但是你已经走上了正确的道路,有时候重用别人的代码也是有好处的,你知道的!:)

有一个jquery progressbar()。。你调查过这件事吗?谢谢你的快速回答,但是我认为progressbar不能帮助我处理我想要的东西,你检查过ign吗?有一个jquery progressbar()。。你调查过这件事吗?谢谢你的快速回答,但是我认为progressbar不能帮助我处理我想要的东西,你检查过ign吗?有一个jquery progressbar()。。你调查过这件事吗?谢谢你的快速回答,但是我认为progressbar不能帮助我处理我想要的东西,你检查过ign吗?有一个jquery progressbar()。。你调查过这件事吗?谢谢你的快速回答,但我不认为progressbar可以帮助我处理我想要的东西,你检查过ign吗?谢谢,现在阅读API,我会尝试做一些代码来测试它,没有问题,如果你满意,请接受我的答案。这也帮了我的忙:)谢谢,现在读API,我会试着做一些代码来测试它,没有问题,如果你满意的话,一定要接受我的答案。这也帮了我的忙:)谢谢,现在读API,我会试着做一些代码来测试它,没有问题,如果你满意的话,一定要接受我的答案。这也帮了我的忙:)谢谢,现在读API,我会试着做一些代码来测试它,没有问题,如果你满意的话,一定要接受我的答案。这也帮了我的忙:)