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

Scrollable areas and parent elements with margins #34

Open
erikhugintech opened this issue Feb 13, 2020 · 0 comments
Open

Scrollable areas and parent elements with margins #34

erikhugintech opened this issue Feb 13, 2020 · 0 comments

Comments

@erikhugintech
Copy link

erikhugintech commented Feb 13, 2020

In an AngularDart app with a scrollable div, the positioning of the drag avatar is off when dragging inside the scrolled div. The following subclass of OriginalAvatarHandler fixed it for me - but I don't know if it'll break in other circumstances:

class CustomAvatarHandler extends OriginalAvatarHandler {
  Point _delta;

  @override
  void dragStart(Element draggable, Point startPosition) {
    Point clientPos = draggable.getBoundingClientRect().topLeft;
    Point offsetPos = draggable.offset.topLeft;
    _delta = Point(offsetPos.x - clientPos.x, offsetPos.y - clientPos.y);
    super.dragStart(draggable, startPosition);
    avatar.style.position = 'fixed';
    setLeftTop(offsetPos);
  }

  @override
  void setLeftTop(Point position) {
    super.setLeftTop(Point(position.x - _delta.x, position.y - _delta.y));
  }
}
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

1 participant