使用旋转和延迟在手写笔中循环迭代

时间:2016-06-27 14:55:17

标签: rotation spinner delay stylus preloader

我想用手写笔创建微调器预加载器(如ios风格)。

我在for元素中有petal个周期。 我的变量delay& degree未正确编译 我需要旋转每个第n个元素并延迟每个动画

请帮帮我。这是我的代码:

    animation a-preloader 1s infinite linear
    delay = 0s
    degree = 0deg
    for num in (1..12)
        &:nth-child({num})
            animation-delay delay
            transform rotate(degree)
            delay = delay + 0.083s
            degree = degree + 30deg

And here is my playground Codepen

预期结果:

preloader

1 个答案:

答案 0 :(得分:1)

我们需要声明增量

delay = delay + 0.083s
degree = degree + 30deg

&:nth-child({num}),如下:

animation a-preloader 1s infinite linear
delay = 0s
degree = 0deg
for num in (1..12)
    &:nth-child({num})
        animation-delay delay
        transform rotate(degree)
    delay = delay + 0.083s
    degree = degree + 30deg