You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何不使用.animate()减慢jQuery环形进度条动画速度

如何减慢环形进度条的动画速度?

你需要减慢环形进度条的动画速度,当前默认动画时长为400ms,而你的代码使用的是circleProgress插件而非.animate()方法,只需在插件配置中添加duration参数即可调整:

修改后的代码

$(document).ready(function ($) {
  function animateElements() {
    $(".progressbar").each(function () {
      var elementPos = $(this).offset().top;
      var topOfWindow = $(window).scrollTop();
      var percent = $(this).find(".circle").attr("data-percent");
      var percentage = parseInt(percent, 10) / parseInt(100, 10);
      var animate = $(this).data("animate");
      if (elementPos < topOfWindow + $(window).height() - 30 && !animate) {
        $(this).data("animate", true);
        $(this)
          .find(".circle")
          .circleProgress({
            startAngle: -Math.PI / 2,
            value: percent / 100,
            size: 180,
            thickness: 15,
            emptyFill: "#ededed",
            fill: {
              color: "green"
            },
            // 设置动画时长,单位:毫秒
            duration: 1000
          })
          .on(
            "circle-animation-progress",
            function (event, progress, stepValue) {
              $(this)
                .find("div")
                .text((stepValue * 100).toFixed(0) + "%");
            }
          )
          .stop();
      }
    });
  }

  animateElements();
  $(window).scroll(animateElements);
  $(document).unbind("scroll");
});

说明

circleProgress插件原生支持通过duration参数控制动画时长,默认值为400毫秒。你可以将duration设置为更大的数值(比如示例中的1000代表1秒),就能减慢动画的播放速度。

内容的提问来源于stack exchange,提问作者Blake Bringer

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.25 18:12:11