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

What is Framer? Join the Community
Return to index
Nicolas Tilly
Posted Jun 05 - Read on Facebook

Hi all, i'm searching for very simple Framer exemples with conditionals (if else if else). Any idea ? :)

10 Comments

Koen Bok

What about you come up with a very simple example that you'd like to see and I'll make it for you :-)

Nicolas Tilly

For exemple: i want to drag a square and when i dragEnd i want to change the square's color :) # Set background
bg = new BackgroundLayer backgroundColor: "#28affa"

# Create layer
layerA = new Layer
width: 250
height: 250
backgroundColor: "#fff"
borderRadius: 8

layerA.center()

# Enable dragging
layerA.draggable.enabled = true

layerA.on Events.Drag, ->
if layerA.onDragEnd == true
backgroundColor: "#000"

Koen Bok

But you don't need conditionals for this though :-)

Nicolas Tilly

Thanks ! it works;) but I also want to know how to work with conditionals.

Nicolas Tilly

For exemple, i drag a square and i want to put it on another then something happen :)

Koen Bok

Homework: make it work only if layerA is _entirely_ is in layerB. Hint: you need to check 4 points rather then one.

Nicolas Tilly

Thanks Koen Bok

Read the entire post on Facebook