set-active.mjs 626 B

12345678910111213141516171819202122232425262728
  1. import { isDragging } from './is-active.mjs';
  2. function setDragLock(axis) {
  3. if (axis === "x" || axis === "y") {
  4. if (isDragging[axis]) {
  5. return null;
  6. }
  7. else {
  8. isDragging[axis] = true;
  9. return () => {
  10. isDragging[axis] = false;
  11. };
  12. }
  13. }
  14. else {
  15. if (isDragging.x || isDragging.y) {
  16. return null;
  17. }
  18. else {
  19. isDragging.x = isDragging.y = true;
  20. return () => {
  21. isDragging.x = isDragging.y = false;
  22. };
  23. }
  24. }
  25. }
  26. export { setDragLock };