Skip to content

Instantly share code, notes, and snippets.

@colinfwren
Created August 27, 2021 12:14
Show Gist options
  • Save colinfwren/b6db03c1db29555669e6cc054953b47d to your computer and use it in GitHub Desktop.
Save colinfwren/b6db03c1db29555669e6cc054953b47d to your computer and use it in GitHub Desktop.
Drag Bounds Function for Control Point
function dragBoundFunc(pos, axis, anchorRef) {
const staticPos = anchorRef.current.getAbsolutePosition();
const otherAxis = axis === 'y' ? 'x' : 'y';
return {
[axis]: pos[axis],
[otherAxis]: staticPos[otherAxis]
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment