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

What is Framer? Join the Community
Return to index
Amrit Mazumder
Posted Jun 21 - Read on Facebook

n00b Q: Is there a way to trigger an event based on the proximity of the layer to the top of the browser?

Im trying to get a button to be "fixed" initially, but then "relative" after I scroll past a point...

6 Comments

Eric Eriksson

There is, yes. I think you can do it using an if-statement. Not sure about the exact code at the moment, but something like below:

if (
y.YourLayer >= [the y value where you want it to trigger] ) {
yourFunctionHere()
}
else {
doSomethingElse()
}

We can have a look at your code tomorrow if you like. I'm sure we can figure it out, I've done something similar in the past.

Amrit Mazumder

Sounds good man...I've done it with jQuery before, just can't figure out how to do it with Framer...

Min-Sang Choi

I'm not sure if I understood what you want. but here it goes : http://codepen.io/radiofun/pen/gsBuz you also can get event DragStart / Move / End to catch y position.

Amrit Mazumder

This really helps! How did you get the top icon layer to behave as a fixed layer?

Min-Sang Choi

Amrit Mazumder you can fix the position by setting draggable.enabled as false. I change the source on codepen, check it.

Amrit Mazumder

layer.draggable.enabled = false did not work for me...I swapped the values in the Codepen you provided and the layer (framer icon) behaved exactly the same...Thanks for helping me out !

Read the entire post on Facebook