We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Trying to enhance the library to limit dx and dy values for useDrag, motivation being limit the allowed distance for drag operation.
dx
dy
useDrag
For example, without dx restrictions:
After the suggested change:
I wanted to confirm my naive implementation before opening a PR:
restrict
restrict?: { xMin?: number; xMax?: number; yMin?: number; yMax?: number; dxMax?: number; // new dyMax?: number; // new dxMin?: number; // new dyMin?: number; // new };
let dx = dragPoint.x - x; let dy= dragPoint.y - y; if ( typeof restrict.dxMax === "number" && _dx > restrict.dxMax) { dx = restrict.dxMax; } if (typeof restrict.dyMax === "number" && _dy > restrict.dyMax) { dy = restrict.dyMax; } if (typeof restrict.dxMin === "number" && _dx < restrict.dxMin) { dx = restrict.dxMin; } if (typeof restrict.dyMin === "number" && _dy < restrict.dyMin) { dy = restrict.dyMin; } return { ...currState, dx, dy, };
Would appreciate weighing in on this approach.
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Trying to enhance the library to limit
dx
anddy
values foruseDrag
, motivation being limit the allowed distance for drag operation.For example, without
dx
restrictions:currents-2024-08-05-16.05.56.mp4
After the suggested change:
currents-2024-08-05-16.04.55.mp4
I wanted to confirm my naive implementation before opening a PR:
restrict
Would appreciate weighing in on this approach.
The text was updated successfully, but these errors were encountered: