This is a read-only archive of the Framer Community on Facebook.

What is Framer? Join the Community
Return to index
Baisampayan Saha
Posted Jul 28 - Read on Facebook

Hi Guys...need a help!

Can I define states inside a function?
eg:
someFunction = ->
layer = new Layer

layer.states.add
1:
scale : 20
2:
scale: 1

button.onTap ->
someFunction()

I was trying something similar to this. But it was not working out! What can do to toggle between states that is defined inside a function?

3 Comments

Baisampayan Saha

Koen Bok But that does not work when I put the layer inside the function, instead I get an error saying can't find variable layer rippleBackground = (event,layer) ->
layer = new Layer
width: 79
height: 79
borderRadius: "50%"
backgroundColor: "#FFBB0E"
midX: event.offsetX
midY: event.offsetY
superLayer: buttonRippleContainer

layer.states.add
1:
scale : 20
2:
scale: 1
opacity: 0.1

layer.states.animationOptions =
time: 1
curve: "ease-out

Douwe Homans

it's hard to see without indentation, but I guess your 'layer.states.add' is not indented enough; therefor not part of the scope of the rippleBackgroundLayer event-function.

Read the entire post on Facebook