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

What is Framer? Join the Community
Return to index
Nick Bewley
Posted Sep 19 - Read on Facebook

On the draggable examples page we have this:

# Enable dragging
topScreen.draggable.enabled = true
topScreen.draggable.speedY = 0

# Prevent dragging left
topScreen.draggable.maxDragFrame = topScreen.frame
topScreen.draggable.maxDragFrame.width *= 2

which allows dragging from left to right. I'm trying to figure out the logic here so that I can switch the functionality to:

— allow drag from right to left
— disable left to right

Any ideas that would help? Thanks a ton!

3 Comments

Seoh Char

topScreen.on Events.DragMove, (e, layer) ->
topScreen.draggable.maxDragFrame.x = layer.x
just a trick. but need to handle maxDragFrame.width in event, coz maxX(x+width) is moved accordingly x

Min-Sang Choi

or you can just add a line of code in that example. topScreen.draggable.maxDragFrame.x = topScreen.x-topScreen.width

Nick Bewley

Awesome thanks Min-Sang Choi. Anyone have any ideas about what I would do if I wanted to add these properties to multiple layers? Something like `draggableLayers = topScreen, bottomScreen`, then something like `draggableLayers.draggable.enabled = true`? Thanks for any ideas!

Read the entire post on Facebook