gpt4 book ai didi

javascript - 使用 Jquery 进行动画(条形随着时间的推移而填满)(建议)

转载 作者:行者123 更新时间:2023-11-28 20:01:49 24 4
gpt4 key购买 nike

我想复制与 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);

}

谢谢!

最佳答案

http://jqueryui.com/progressbar/

你可以试试这个..

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

关于javascript - 使用 Jquery 进行动画(条形随着时间的推移而填满)(建议),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21549324/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com