Bug Tracker

Opened 15 years ago

Closed 15 years ago

#2637 closed bug (fixed)

[BUG+PATCH] ui.droppables: calc position creates undroppables on elements not yet added to DOM

Reported by: spurkis Owned by: braeker
Priority: major Milestone: 1.2.4
Component: ui Version: 1.2.3
Keywords: ui droppables proportions Cc:
Blocked by: Blocking:


(also posted to jQuery UI Google Group) Hi there,

I've been trying to create DOM elements, make them droppable, and add them in one fell swoop... pretty much ala:

var $li1 = $('<li class="one">foo</li>'); $li1.draggable({opacity: 0.5, helper: 'clone'});

var $li2 = $('<li>bar</li>'); $li.droppable({

accept: '.one', tolerance: 'pointer', activeClass: 'droppable-active', hoverClass: 'droppable-hover', refreshPositions: true, drop: function(ev, ui) {

alert('dropped '+ui.draggable+' onto '+this+'!');



I couldn't figure out why the droppables I was creating were getting 'droppable-active' set but never 'droppable-hover'. And it worked for other droppables I had on the page.

When I looked through ui.droppable.js, I found out that 'refreshPositions' doesn't quite do what it says on the tin - it refreshes the offsets, but not the proportions.

I've uploaded a patch that does just that (though I can't figure out how to link to it from here? it's called ui.droppable.js-recalc- position.patch). Note that I opted to do a recalcProportions() on droppable.activate() instead of in the drag() method like prepareOffsets() because I wanted to reduce the time spent calculating... others may have different opinions. I also made the mouse pointer calcs a bit less repetitive (and prolly 1x10e-100 s faster ;-)

Hope this helps, -Steve

Attachments (1)

ui.droppable.js-recalc-position.patch (2.2 KB) - added by spurkis 15 years ago.
patch for this bug

Download all attachments as: .zip

Change History (7)

Changed 15 years ago by spurkis

patch for this bug

comment:1 Changed 15 years ago by paul

Owner: changed from paul to braeker

comment:2 Changed 15 years ago by scott.gonzal

I haven't tested this at all, but try just changing line 226 of ui.droppable.js from

m[i].item.proportions = ...


m[i].proportions = ...

comment:3 Changed 15 years ago by scott.gonzal

Disregard my previous comment, that line was correct. Paul's going to fix those inconsistencies (#2638).

comment:4 Changed 15 years ago by spurkis

Thanks Scott & Paul!

comment:5 Changed 15 years ago by scott.gonzal

Eduardo, can you verify whether or not this problem still exists? Paul and I both feel that the patch is unnecessary (it's doing redundant work). If the problem still exists, there is a bug or typo somewhere.

comment:6 Changed 15 years ago by paul

Resolution: fixed
Status: newclosed

I rechecked, this should be fixed!

Note: See TracTickets for help on using tickets.