STUDYING DRAG AND DROP: PART 1, JUST DRAG SOMETHING
Despite many years of web development, there is one skill that I've never truly mastered: drag and drop. I've mostly relied on open source libraries and existing frameworks, but the actual mechanism has always eluded me.
I decided to do something about that. I made a "lesson plan" for learning how to do drag and drop, and I'm going to share those lessons and the outcome of them. Three things:
- This is entirely about synthetic drag-and-drop; I will not be using the HTML5 "drag and drop"
library; this will be entirely about using pointers and windows, and
ondragandondropwill not be events in our vocabulary. - My examples will be entirely within the DOM. I will be using Lit, not React. We will work directly with the events as they occur within the browser. React teaches you to treat the DOM as a hostile environment, and I'm here to tell you that the DOM is an elegant and beautiful thing and you should appreciate it for what it is.
- I'm going to use Typescript, because Typescript will be extremely helpful in discriminating between states in a drag-and-drop system.
All right? Onward!
Continue Reading