© 2013, Martin Rinehart
In concept, dragging is simple. If you get a
mousedown event on a draggable part, you start dragging. Then you respond to
mousemove events by making an appropriate adjustment in the size or position of the window being dragged. (No need to worry about drop zones for window drags.)
In practice, however, it's not that simple. The DOM API fires
First, we create a queue for mouse events. We can stuff them into this queue as fast as they arrive; process them as time permits.
Second, we note that "processing" really means updating x,y coordinates. Dragging the right side? Update the width. Dragging the lower-right corner? Update width and height. Top? Update the top and height, and so on. We also note that these are all adjustments to the
pos_size and that changing the
pos_size is foolish if your next action is to change the
pos_size again. You can take the last entry from the mouse event queue and discard the rest. Ergo a special queue. Incoming? Empty the queue and add the new event.
Feedback: MartinRinehart at gmail dot com
# # #