Skip to main content

Search and Top Navigation

#8218 closed bug (worksforme)

Opened March 24, 2012 11:48PM UTC

Closed March 25, 2012 01:02PM UTC

Last modified March 28, 2012 08:41PM UTC

Drag event firing even when draggable has not moved. ui.position is updating even if item did not move along axis.

Reported by: sp2 Owned by:
Priority: minor Milestone: 1.9.0
Component: ui.draggable Version: 1.8.18
Keywords: Cc:
Blocked by: Blocking:
Description

There are lots of situations where a mouse down on a draggable, and a slight drag will not actually move a draggable. Examples: draggable is constrained, has an axis setting or draggable has a grid. In these situations, even if the object does not move, the start, drag and stop events still fire, and drag constantly fires while moving cursor, even though object does not move. Worse yet, the ui.originalPosition setting appears to be set sort of randomly to begin with, and ui.position is showing a change along the x axis, even when axis is constrained.

See http://jsfiddle.net/spekary/JxRYP/, based on jQuery UI example code, modified to have a grid and axis setting.

Steps to reproduce:

1) Click top text and move cursor slightly, then release. Will show start, drag and stop events firing even though item has not moved.

2) Click top text and drag down about 100 pixels. Click again and drag up. Note that 'drag from' text taken from ui.originalPosition appears random.

3) Click top text and drag to right. Note that 'drag to' left coordinate is changing, taken from ui.position.left, even though object is not moving left or right.

Attachments (0)
Change History (4)

Changed March 25, 2012 01:02PM UTC by scottgonzalez comment:1

resolution: → worksforme
status: newclosed

This is correct. The events occur every time a drag can happend the position indicates where the user is trying to move to the item to.

Changed March 25, 2012 06:42PM UTC by sp2 comment:2

Bear with me a bit while I push back on that a little. Perhaps I have a different expectation of what the drag event is supposed to be.

I do see that the description in the documentation is 'This event is triggered when the mouse is moved during the dragging.' I guess my expectation is that the event should be triggered when the item is moved, not when the mouse is moved, since there are other ways to track mouse move events. I am not sure why I would want to see drag events constantly if no drag happened. By setting a grid, I purposely am saying, 'Don't move until you go a certain distance.' Why would I want to know that the user tried to move it, but it didn't move yet because the user hadn't dragged far enough?

Re: ui.position, if I set an axis, why would I want to know in the drag event what would have happened if I didn't specify an axis setting? It is strange to me that ui.position.left is changing if I set axis to 'y'. In addition, if I have an axis setting of 'y', and have a grid setting of '5', and I drag to the right, I see multiples of 5 in ui.position.left, even though it doesn't move in that direction. I would think the developer would want to know the actual position of the draggable, not a hypothetical position if the axis value had not been set.

Finally, is ui.originalPosition supposed to be valid, and what should it be set to? In particular, I am noticing that the first time you drag, it is set correctly for drag event and stop event. But if you click on the same item and drag it again, it gets set to what appears to be a random value. I would think it should be set to the top-left of the draggable object at the moment the item is clicked the 2nd time.

If its still decided to keep the drag event as is, then I would request a 'move' event, that would fire each time the draggable moved, and only when the draggable actually moved, and would update ui.position with the new, actual, top-left location of the draggable, and would update ui.originalPosition to the top-left of the draggable each time the object was clicked.

Changed March 26, 2012 02:39PM UTC by scottgonzalez comment:3

This discussion will be way too large to have here. Feel free to post your questions/ideas on the forum or the planning wiki where we're redesigning the interaction plugins.

Changed March 28, 2012 08:41PM UTC by sp2 comment:4

OK, I posted a question in the forums. I can see from the documentation that the behavior of originalPosition is not specified, and the Drag event could be interpreted as dragging on mouseMove events, but the documentation also says that for all events:

ui.position - current position of the helper as { top, left } object, relative to the offset element

And this simply isn't true if you set an axis constraint. So, bottom line, either the doc is wrong on this, or its a bug.