]> source.dussan.org Git - jquery-ui.git/commitdiff
sortable: connected lists items are not refreshed until you actually move into the...
authorPaul Bakaus <paul.bakaus@googlemail.com>
Tue, 24 Jun 2008 15:28:12 +0000 (15:28 +0000)
committerPaul Bakaus <paul.bakaus@googlemail.com>
Tue, 24 Jun 2008 15:28:12 +0000 (15:28 +0000)
ui/ui.draggable.js
ui/ui.sortable.js

index 8c52e4855fc0bc3f682e395ed96d4904ae7576b4..ff9d7465a05f08fc2ff56e23b53d3c143bb9be50 100644 (file)
@@ -443,7 +443,7 @@ $.ui.plugin.add("draggable", "connectToSortable", {
                                        instance: sortable,
                                        shouldRevert: sortable.options.revert
                                });
-                               sortable.refresh();     //Do a one-time refresh at start to refresh the containerCache  
+                               sortable.refreshItems();        //Do a one-time refresh at start to refresh the containerCache  
                                sortable.propagate("activate", e, inst);
                        }
                });
@@ -502,8 +502,10 @@ $.ui.plugin.add("draggable", "connectToSortable", {
                                        this.instance.options.helper = function() { return ui.helper[0]; };
                                
                                        e.target = this.instance.currentItem[0];
-                                       this.instance.mouseCapture(e, true, true);
+                                       this.instance.mouseCapture(e, true);
                                        this.instance.mouseStart(e, true, true);
+                                       
+                                       console.log(this.instance.items);
 
                                        //Because the browser event is way off the new appended portlet, we modify a couple of variables to reflect the changes
                                        this.instance.offset.click.top = inst.offset.click.top;
index 8d5c67c4bec80463fe778356d5e826cffe85dbcc..ccd987e3352505ad8e210d8ef52fd3ebf9461315 100644 (file)
@@ -172,6 +172,7 @@ $.widget("ui.sortable", $.extend($.ui.mouse, {
                                $.data(this, 'sortable-item', queries[i][1]); // Data for target checking (mouse manager)
                                items.push({
                                        item: $(this),
+                                       instance: queries[i][1],
                                        width: 0, height: 0,
                                        left: 0, top: 0
                                });
@@ -190,14 +191,23 @@ $.widget("ui.sortable", $.extend($.ui.mouse, {
                        };
                }
 
-               for (var i = this.items.length - 1; i >= 0; i--){
+               for (var i = this.items.length - 1; i >= 0; i--){               
+                       
+                       //We ignore calculating positions of all connected containers when we're not over them
+                       if(this.items[i].instance != this.currentContainer && this.currentContainer && this.items[i].item[0] != this.currentItem[0])
+                               continue;
+                               
                        var t = this.items[i].item;
+                       
                        if(!fast) this.items[i].width = (this.options.toleranceElement ? $(this.options.toleranceElement, t) : t).outerWidth();
                        if(!fast) this.items[i].height = (this.options.toleranceElement ? $(this.options.toleranceElement, t) : t).outerHeight();
+                       
                        var p = (this.options.toleranceElement ? $(this.options.toleranceElement, t) : t).offset();
                        this.items[i].left = p.left;
                        this.items[i].top = p.top;
+                       
                };
+               
                for (var i = this.containers.length - 1; i >= 0; i--){
                        var p =this.containers[i].element.offset();
                        this.containers[i].containerCache.left = p.left;
@@ -205,6 +215,7 @@ $.widget("ui.sortable", $.extend($.ui.mouse, {
                        this.containers[i].containerCache.width = this.containers[i].element.outerWidth();
                        this.containers[i].containerCache.height = this.containers[i].element.outerHeight();
                };
+               
        },
        destroy: function() {
                this.element
@@ -265,11 +276,10 @@ $.widget("ui.sortable", $.extend($.ui.mouse, {
                                                        this.placeholder = null;;
                                                }
                                                
-                                               
-                                               itemWithLeastDistance ? this.rearrange(e, itemWithLeastDistance) : this.rearrange(e, null, this.containers[i].element);
+                                               this.currentContainer = this.containers[i];
+                                               itemWithLeastDistance ? this.rearrange(e, itemWithLeastDistance, null, true) : this.rearrange(e, null, this.containers[i].element, true);
                                                this.propagate("change", e); //Call plugins and callbacks
                                                this.containers[i].propagate("change", e, this); //Call plugins and callbacks
-                                               this.currentContainer = this.containers[i];
 
                                        }
                                        
@@ -518,9 +528,9 @@ $.widget("ui.sortable", $.extend($.ui.mouse, {
                return false;
                
        },
-       rearrange: function(e, i, a) {
+       rearrange: function(e, i, a, hardRefresh) {
                a ? a.append(this.currentItem) : i.item[this.direction == 'down' ? 'before' : 'after'](this.currentItem);
-               this.refreshPositions(true); //Precompute after each DOM insertion, NOT on mousemove
+               this.refreshPositions(!hardRefresh); //Precompute after each DOM insertion, NOT on mousemove
                if(this.options.placeholder) this.options.placeholder.update.call(this.element, this.currentItem, this.placeholder);
        },
        mouseStop: function(e, noPropagation) {