2016-12-02 60 views
0

按照Framer研討會的例子逐字逐句地,由於某種原因無法獲得有條件的聲明。成幀器/ Coffescript有條件的不按預期方式工作

此代碼運行正常

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)" 

回答

2

似乎成幀器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)" 
+1

你可以閱讀更多關於動畫的API的變化這裏:https://github.com/koenbok/Framer/wiki /動畫升級指南 – Niels

+0

@Niels:這將是未來的優秀參考,謝謝。 – counselor

相關問題