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

Click n drag #286

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open

Click n drag #286

wants to merge 7 commits into from

Conversation

allan-bonadio
Copy link

This is a click-drag-drop example, using regular mouse events, not d&d events. I was surprised that MDN didn't seem to have such an example yet! I've been doing interaction like this for 10+ years, and I've picked up lots of unobvious tips and tricks, in many cases, the hard way.

I've been paying attention to the fact that other programmers will copy/paste into their own code, trying to make the code general, with lots of comments.

I've also added a set of suggestions for more modern methods and user-friendly effects. This'll work on all browsers, as is, from the last 10 years.

@allan-bonadio allan-bonadio requested a review from a team as a code owner November 30, 2024 22:55
@allan-bonadio allan-bonadio requested review from bsmth and removed request for a team November 30, 2024 22:55
@allan-bonadio
Copy link
Author

my rationale for this PR is that I once had a coworker whose task was to make a list re-arrangeable by clicking and dragging elements up or down. She used the full d&d API, which was way overkill. She had to design some code-independent data format, etc. Despite the fact that the data was in the same address space, was involved with the UI in that page, and limited to its enclosing element. And was limited to the associated JS code and the backend managing it.

d&d is for dragging to and from other apps, or at least other web pages, not within the same JS global space. These should be done with old fashioned mousedown/move/up events, as this example illustrates. There's probably a lot of other programmers who have fallen into this trap. Ultimately, I want the d&d article to point this out, but there's some more contributions I need to do first, after this and the 'mouse & pointer event pages updates #36993' PR .

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

Successfully merging this pull request may close these issues.

1 participant