react-draggable icon indicating copy to clipboard operation
react-draggable copied to clipboard

Is there any way to handle drag direction?

Open tengemakers opened this issue 6 years ago • 1 comments

I need a way to handle if drag is going up or down, left of right? Anyone had experience with it?

tengemakers avatar Mar 17 '20 12:03 tengemakers

If you take a look at the API

type DraggableEventHandler = (e: Event, data: DraggableData) => void | false;
type DraggableData = {
  node: HTMLElement,
  // lastX + deltaX === x
  x: number, y: number,
  deltaX: number, deltaY: number,
  lastX: number, lastY: number
};

you'll probably can get the direction by computing Math.sign(deltaX) or Math.sign(deltaY)

dmytro-shchurov avatar Mar 23 '20 09:03 dmytro-shchurov