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

Strange drag + release behavior for button #45

Open
MartinSStewart opened this issue Feb 28, 2022 · 1 comment
Open

Strange drag + release behavior for button #45

MartinSStewart opened this issue Feb 28, 2022 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@MartinSStewart
Copy link
Contributor

MartinSStewart commented Feb 28, 2022

When opening https://elm-designer.passiomatic.com/ for the first time (or after I clear local storage) if I click and drag a primary button onto the page, and then drag the primary button after I've placed it, releasing it will cause the viewport to scroll really far down and to the right.

Browser: Firefox
OS: Windows 10

@passiomatic passiomatic added the bug Something isn't working label Feb 28, 2022
@passiomatic
Copy link
Owner

passiomatic commented Feb 28, 2022

As you have written on Slack the bug is always reproducible if one releases the mouse over part of a page, while it always works fine if one releases outside of a page.

The underlying issue is that drop event offsetX and offsetY values are set differently if user drops the page on a empty area of the workspace or not (this works the same with other mouse events too). In detail:

  1. Blank area: the event offset values refer to the top left corner of the workspace - so we can use them directly to abs. position the page. This the ideal scenario that works nowadays.
  2. Over another page: the event offset values now refer to the top left corner on the overlapped page and this clearly cannot work. So we need a way to sum the offsets and come up with the final values. The issue is more complex though: if the overlapped page contains children these needs to be taken into account, because the offset may be calculated from one of them.

In the second case I guess we can track event.currentTarget and event.target and see if they are different.

Seems likes others are having the same issue norpan/elm-html5-drag-drop#24

@passiomatic passiomatic self-assigned this Jun 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants