Animation 如何使用Framer.js中的CoffeeScript制作动画无限循环?

Animation 如何使用Framer.js中的CoffeeScript制作动画无限循环?,animation,coffeescript,framerjs,Animation,Coffeescript,Framerjs,我试图在Framer.js中为屏幕上的元素制作一个简单的脉冲动画,现在它看起来像这样: element.animate properties: scale:1.3 element.on Events.AnimationEnd,-> this.scale = 1 locationUn.animate properties: scale:1.3 circle = new Layer() circle.style.borderRadius = "100%

我试图在Framer.js中为屏幕上的元素制作一个简单的脉冲动画,现在它看起来像这样:

element.animate
    properties: scale:1.3
element.on Events.AnimationEnd,->
    this.scale = 1
    locationUn.animate
        properties: scale:1.3
circle = new Layer()
circle.style.borderRadius = "100%"
circle.backgroundColor = "white"
circle.center()

outwards = new Animation({
    layer: circle,
    properties: {scale: 1.3},
    curve: "ease-in-out"
})

inwards = outwards.reverse()

outwards.on(Events.AnimationEnd, inwards.start)
inwards.on(Events.AnimationEnd, outwards.start)

outwards.start()
基本上,当屏幕加载时,元素将被放大,动画结束后,它将被强制返回到比例1并再次运行动画;但这种解决方案并不优雅,动画似乎非常突然

我对CoffeeScript还不熟悉……是否有编写无限循环来检查这样的条件

checker = true

while(checker == true){
    run animation
    if(some events occurs){
        checker = false
    }
}
....

如何在CoffeeScript中实现这一点?

您可以创建如下循环脉冲:

element.animate
    properties: scale:1.3
element.on Events.AnimationEnd,->
    this.scale = 1
    locationUn.animate
        properties: scale:1.3
circle = new Layer()
circle.style.borderRadius = "100%"
circle.backgroundColor = "white"
circle.center()

outwards = new Animation({
    layer: circle,
    properties: {scale: 1.3},
    curve: "ease-in-out"
})

inwards = outwards.reverse()

outwards.on(Events.AnimationEnd, inwards.start)
inwards.on(Events.AnimationEnd, outwards.start)

outwards.start()

您是否有理由认为这在coffeescript中与javascript中有所不同?上面的咖啡脚本看起来不错,可以按预期工作。脉冲动画可以工作,但动画非常突然(从比例1.3直接跳到1,没有过渡)。我正在寻找一种编写无限循环的通用方法,希望能使它变得平滑谢谢!我没有意识到我也可以将动画对象化