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

What is Framer? Join the Community
Return to index
Jackson Chu
Posted Jan 20 - Read on Facebook

I have a horizontal draggable layer inside a vertical draggable layer, and would like to be able to differentiate between when I'm dragging up/down vs. left/right. The problem I'm having is when I'm dragging horizontally and the vertical drag is also being triggered when fingers don't drag along a perfect x-axis, and vice versa. Is there a way to either trigger some kind of detection for the orientation of the drag accounting for potentially a slight diagonal drag or perhaps in other words define the range for which a drag is horizontal vs. vertical then enable the appropriate draggable layer?

4 Comments

Joshua Tucker

Maybe setup conditionals? Say at DragStart, grab the starting value of both X and Y. On DragMove, create a variable that is the origin value captured at DragStart and subtract by the event.x/y. When it exceeds your threshold, do something.

Peter Ng

what he said you would write that function and say draggable speedY = 0 if xDelta > 15 or something like that.

Jackson Chu

Thanks everyone for the comments!

David E. Chen

FYI Devin Abbott's draggable layers enhancement provides draggable.directionLock. He submitted a pull request so this could be in a future release of Framer.

https://www.facebook.com/groups/framerjs/permalink/624452434348498/
https://github.com/koenbok/Framer/pull/164

Read the entire post on Facebook