Opened 9 years ago
Closed 9 years ago
#9730 closed bug (invalid)
when triggered drop and greedy = true, if DOM changed, drop event occurs again to others
Reported by: | trasyia | Owned by: | trasyia |
---|---|---|---|
Priority: | minor | Milestone: | none |
Component: | ui.droppable | Version: | 1.10.3 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
This is because, drop function calls each droppable and it's not stop until all loop is done.
When drop occurs actually, DOM can be changed and this loop can detect another droppable object.
So, the loop must be stopped when greedy.
drop function is here,
drop: function(draggable, event) { var dropped = false; $.each($.ui.ddmanager.droppables[draggable.options.scope] || [], function() { if(!this.options) { return; } if (!this.options.disabled && this.visible && $.ui.intersect(draggable, this, this.options.tolerance)) { dropped = this._drop.call(this, event) || dropped; } if (!this.options.disabled && this.visible && this.accept.call(this.element[0],(draggable.currentItem || draggable.element))) { this.isout = true; this.isover = false; this._deactivate.call(this, event); } }); return dropped; },
and solutions maybe...
drop: function(draggable, event) { var dropped = false; $.each($.ui.ddmanager.droppables[draggable.options.scope] || [], function() { if(!this.options) { return; } if (!this.options.disabled && this.visible && $.ui.intersect(draggable, this, this.options.tolerance)) { dropped = this._drop.call(this, event) || dropped; if (dropped && this.options.greedy) return false; } if (!this.options.disabled && this.visible && this.accept.call(this.element[0],(draggable.currentItem || draggable.element))) { this.isout = true; this.isover = false; this._deactivate.call(this, event); } }); return dropped; }
Change History (4)
comment:1 Changed 9 years ago by
Owner: | set to trasyia |
---|---|
Status: | new → pending |
comment:2 follow-up: 3 Changed 9 years ago by
Status: | pending → new |
---|
Ok, let's see the logical flow...
'drop' works like this
foreach (droppable_dom) { if (there is no child droppable_dom that is greedy and intersect) { do drop; } }
Let the DOM 1,2,3,4,5,6 is all 'greedy' and 'pointer tolerance' options, and nested like [1 [2 [3 ] ] ] [4 [5 [6 ] ] ].
When the DOM5 dropped to DOM3, there is possibility, DOM2 or DOM4 get drop event.
Because 'foreach' loop run for all droppable DOM 1,2,3,4,5,6, and after DOM5 dropped to DOM3, DOM size can be changed and DOM4 can interset to dropped point.
Or, (I don't know the reaseon) when 'foreach' run for DOM2, DOM3 is not detect as 'child droppable_dom'.
So, I suggest 2 way
- If dopped DOM is greedy, end foreach loop
- Check all droppable DOM first, then do actual drop later.
comment:3 Changed 9 years ago by
Status: | new → pending |
---|
Replying to trasyia:
Ok, let's see the logical flow...
'drop' works like this
foreach (droppable_dom) { if (there is no child droppable_dom that is greedy and intersect) { do drop; } }Let the DOM 1,2,3,4,5,6 is all 'greedy' and 'pointer tolerance' options, and nested like [1 [2 [3 ] ] ] [4 [5 [6 ] ] ].
When the DOM5 dropped to DOM3, there is possibility, DOM2 or DOM4 get drop event.
Because 'foreach' loop run for all droppable DOM 1,2,3,4,5,6, and after DOM5 dropped to DOM3, DOM size can be changed and DOM4 can interset to dropped point.
Or, (I don't know the reaseon) when 'foreach' run for DOM2, DOM3 is not detect as 'child droppable_dom'.
So, I suggest 2 way
- If dopped DOM is greedy, end foreach loop
- Check all droppable DOM first, then do actual drop later.
Hi trasyia,
Can you please provide a test case that shows this behavior in action? You can use this as a starting point: http://jsfiddle.net/tj_vantoll/8RtqV/. I'm mostly wondering what specific DOM changes you are making in the drop
event such that it affects other droppables.
comment:4 Changed 9 years ago by
Resolution: | → invalid |
---|---|
Status: | pending → closed |
Because we get so many tickets, we often need to return them to the initial reporter for more information. If that person does not reply within 14 days, the ticket will automatically be closed, and that has happened in this case. If you still are interested in pursuing this issue, feel free to add a comment with the requested information and we will be happy to reopen the ticket if it is still valid. Thanks!
Please provide a reduced test case showing the problem. Also, as the red box says, please do not paste large blocks of code into tickets.