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

What is Framer? Join the Community
Return to index
Junjun Sun
Posted Apr 04 - Read on Facebook

Hi Friends, do you have the problem for the slow of change state in stateCycle function? For example, I have three layer: layer0, layer1 and layer2, and there is a button on the top right side in layer1: When I click the button, the height of layer 0 will change between state big and state small, I want the y position of layer1 and the y position of layer2 both move up and down according to layer0's height (seems layer1 and layer2 stick to layer0).... but in the code of layer2's y position always seems opposite to layer1's maxY. (when layer1's maxY is 1682, layer2's y is 2844; when layer1's maxY is 2844, layer2's y is 1682) So, could someone help me to solve the problem? Many thanks!


Arie Aulia Nugraha

shouldn't layer1. animate
y : layer0.maxY


Junjun Sun

you find the same question for layer1, if i change the layer1.animate y:layer0.maxY , layer1.y always not the same of layer0.maxY (it is the same question as what i said in the problem's description)

Arie Aulia Nugraha

my guess is when layer 0 cycle state to another state, there should be a delay (Utils.delay) before animating layer1 and layer2 so then they can get the final height of layer 0

Mike Johnson

Take a look at the change event in the docs. On phone at the moment but you can use something like

layer0.on "change:height", ->
layer1.y = layer0.height

This should make the layer0 height drive the layer1 y position and you don't need to animate it anymore, just change the state of layer0

Read the entire post on Facebook