Skip to content
New issue

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

Create IDragger and IDraggable interfaces #7838

Closed
BeksOmega opened this issue Feb 7, 2024 · 0 comments
Closed

Create IDragger and IDraggable interfaces #7838

BeksOmega opened this issue Feb 7, 2024 · 0 comments
Assignees

Comments

@BeksOmega
Copy link
Collaborator

BeksOmega commented Feb 7, 2024

interface IDragger {
  constructor(dragged: IDraggable);

  // Lets the dragger handle any drag startup.
  onDragStart(e: PointerEvent);

  // Lets the dragger calculate where the element should actually be moved to.
  onDrag(e: PointerEvent, totalDelta: Coordinate);

  // Lets the dragger handle any drag cleanup.
  onDragEnd(e: PointerEvent);
}
interface IDraggable {
  // Returns true if the element is currently movable. False otherwise.
  isMovable(e: PointerEvent): boolean;

  // Returns the current location of the draggable in workspace coordiantes.
  getLocation(): Coordinate;

  // Lets the element handle any drag startup (e.g. moving to the front of the workspace)
  startDrag(e: PointerEvent);

  // Lets the element handle moving the new location, and updating any visuals based
  // on that (e.g. connection previews).
  drag(newLoc: Coordinate, target: IDragTarget, e?: PointerEvent);

  // Lets the element handle any drag cleanup.
  endDrag(e: PointerEvent);
}

See PR #7846 for initial implementation.

@BeksOmega BeksOmega self-assigned this Feb 7, 2024
@BeksOmega BeksOmega assigned cpcallen and unassigned BeksOmega Feb 9, 2024
@cpcallen cpcallen changed the title Implement IDragger and IDraggable interfaces. Create IDragger and IDraggable interfaces Mar 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants