在没有动画的情况下将进度条重置为零(在引导程序中)

Reset progress bar to zero without animation (in bootstrap)

本文关键字:引导程序 动画 情况下      更新时间:2023-11-10

我有多个操作要执行,我使用引导进度条来显示每个操作的进度。每个操作完成后,使用下面的代码行将进度条设置为零$('.progress').attr('style',"width:0%")

但,这会反过来动画化,对于用户来说,它看起来像是应用程序正在撤消以前执行的操作。

如何在没有反向动画效果的情况下立即重置进度条?

您可以删除进度条的转换,如回答中所述

.notransition {
  -webkit-transition: none !important;
  -moz-transition: none !important;
  -o-transition: none !important;
  -ms-transition: none !important;
  transition: none !important;
}
$(".progress-bar").addClass("notransition");
$('.progress-bar').attr('style', "width: 0%");

如果你愿意,你可以通过删除非转换类再次启用转换

$(".progress-bar").removeClass("notransition");