0

逐字遵循 Framer 研讨会示例,由于某种原因无法使条件语句起作用。

此代码按预期运行

layerA = new Layer
    backgroundColor: "#fff"
    borderRadius: 4
    width: 200
    height: 200
    rotation: 0


layerA.center()

layerA.states.add
  grow:
    scale: 1.5
    rotation: 90

shrink:
    scale: 1
    rotation: 0

layerA.states.animationOptions =
  curve: "spring(400, 50, 30)"

layerA.onClick ->
    layerA.states.next("grow", "shrink")

但是,如果我在下面添加条件,它会被忽略吗?

    if layerA.states.current is "grow"
        layerA.states.animationOptions = 
        curve: "ease"
        time: 2
    else 
        layerA.states.animationOptions =
        curve: "spring(400,50,30)"
4

1 回答 1

2

似乎 Framer API 已更新,现在.name必须附加该属性才能states.current使其正常工作。

所以下面的条件

if layerA.states.current is "grow"
    layerA.states.animationOptions = 
    curve: "ease"
    time: 2
else 
    layerA.states.animationOptions =
    curve: "spring(400,50,30)"

... 会成为

if layerA.states.current.name is "grow"
    layerA.states.animationOptions = 
    curve: "ease"
    time: 2
else 
    layerA.states.animationOptions =
    curve: "spring(400,50,30)"
于 2016-12-02T22:53:35.453 回答