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

What is Framer? Join the Community
Return to index
Chris Lee
Posted Jun 20 - Read on Facebook

What's the best way to set limits on the area a layer can be dragged? I used to do this with something in the DragMove handler like "if (layer.x < whatever) layer.x = whatever", but that appears to no longer work in Framer 3.


Tisho Georgiev

You can still use the DragMove handler, but change the speed of the draggable to 0 when the layer goes out of bounds, instead of resetting its position:

myLayer.on(Events.DragMove, function() {
if (myLayer.x > 200) {
myLayer.draggable.speedX = myLayer.draggable.speedY = 0

You can also use an undocumented property of draggable called maxDragFrame. It defines the bounding rectangle that a draggable layer can move in. You use it like this (assuming myLayer is inside a containerLayer):
myLayer.draggable.maxDragFrame = containerLayer.frame

Koen Bok

And ideas to improve maxDragFrame are welcome!

Aaron Carámbula

Ooh how about maxDragBehavior = [endDrag | freeze | resist]

Chris Lee

Thanks for the maxDragFrame tip. I filed this:

Read the entire post on Facebook