jquery - 圆形动画css3和jquery

标签 jquery html css

有没有办法让动画填充运行流畅?

我的意思是说,它滴答作响的每一秒都会从 20 增加到 40,但你会看到它一毫米一毫米地填满圆圈,而不是像现在这样跳跃吗?因为不管我把多长时间作为过渡长度的参数,它看起来仍然是通过跳跃来填充的,而不是平滑的填充。

这是 fiddle

.radial-progress {
@circle-size: 120px;
@circle-background: #d6dadc;
@circle-color: #97a71d;
@inset-size: 90px;
@inset-color: #fbfbfb;
@transition-length: 0.2s;
@shadow: 6px 6px 10px rgba(0,0,0,0.2);

margin: 50px;
width:  @circle-size;
height: @circle-size;

background-color: @circle-background;
border-radius: 50%;
.circle {
    .mask, .fill, .shadow {
        width:    @circle-size;
        height:   @circle-size;
        position: absolute;
        border-radius: 50%;
    }
    .shadow {
        box-shadow: @shadow inset;
    }
    .mask, .fill {
        -webkit-backface-visibility: hidden;
        transition: -webkit-transform @transition-length;
        transition: -ms-transform @transition-length;
        transition: transform @transition-length;
    }
    .mask {
        clip: rect(0px, @circle-size, @circle-size, @circle-size/2);
        .fill {
            clip: rect(0px, @circle-size/2, @circle-size, 0px);
            background-color: @circle-color;
        }
    }
}
.inset {
    width:       @inset-size;
    height:      @inset-size;
    position:    absolute;
    margin-left: (@circle-size - @inset-size)/2;
    margin-top:  (@circle-size - @inset-size)/2;

    background-color: @inset-color;
    border-radius: 50%;
    box-shadow: @shadow;
}

http://jsfiddle.net/32Y8U/523/

谢谢

最佳答案

将间隔设置为当前的 1/10,然后将绘制增量从 20 向下调整为 2,动画会更加流畅。

JSFiddle here .

var drawAmount = 0;
var interval = 0;
setInterval(
     function(){   
         interval = interval + 1;
         if ( interval >= 5 ) {
             drawAmount = drawAmount - 2;
             draw(drawAmount);
         }
         else {
              drawAmount = drawAmount + 2;
              draw(drawAmount);
         }
     },
     100  /* 10000 ms = 10 sec */
);

关于jquery - 圆形动画css3和jquery,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29444084/

相关文章:

jQuery ,未捕获的 TypeError : $(. ..).autoNumeric 不是函数

html - “base.document.layout”对象没有属性 'header' odoo14 - 尝试在报告中显示自定义字段

php - 为什么我按“提交”后页面仍为空白?

html - 使具有负 z-index 的元素的子元素显示在所有其他元素之上

javascript - css 如何避免在此代码中固定高度

javascript - 如何在使用 jquery 将数据发送到数据库时使按钮处于事件状态?

http - jQuery Ajax : redirect to other pages without wait the result

css - Quasar 表根据一个单元格中的值更改整行的样式

html - 合并 :not() and :first-child() selectors

javascript - 如何创建输入 id 的数组