Changeset 334

Show
Ignore:
Timestamp:
06/24/08 08:28:12 (21 months ago)
Author:
paul.bakaus
Message:

sortable: connected lists items are not refreshed until you actually move into the connected list - this improves performance for connected lists

Location:
trunk/ui
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/ui/ui.draggable.js

    r329 r334  
    444444                                        shouldRevert: sortable.options.revert 
    445445                                }); 
    446                                 sortable.refresh();     //Do a one-time refresh at start to refresh the containerCache   
     446                                sortable.refreshItems();        //Do a one-time refresh at start to refresh the containerCache   
    447447                                sortable.propagate("activate", e, inst); 
    448448                        } 
     
    503503                                 
    504504                                        e.target = this.instance.currentItem[0]; 
    505                                         this.instance.mouseCapture(e, true, true); 
     505                                        this.instance.mouseCapture(e, true); 
    506506                                        this.instance.mouseStart(e, true, true); 
     507                                         
     508                                        console.log(this.instance.items); 
    507509 
    508510                                        //Because the browser event is way off the new appended portlet, we modify a couple of variables to reflect the changes 
  • trunk/ui/ui.sortable.js

    r332 r334  
    173173                                items.push({ 
    174174                                        item: $(this), 
     175                                        instance: queries[i][1], 
    175176                                        width: 0, height: 0, 
    176177                                        left: 0, top: 0 
     
    191192                } 
    192193 
    193                 for (var i = this.items.length - 1; i >= 0; i--){ 
     194                for (var i = this.items.length - 1; i >= 0; i--){                
     195                         
     196                        //We ignore calculating positions of all connected containers when we're not over them 
     197                        if(this.items[i].instance != this.currentContainer && this.currentContainer && this.items[i].item[0] != this.currentItem[0]) 
     198                                continue; 
     199                                 
    194200                        var t = this.items[i].item; 
     201                         
    195202                        if(!fast) this.items[i].width = (this.options.toleranceElement ? $(this.options.toleranceElement, t) : t).outerWidth(); 
    196203                        if(!fast) this.items[i].height = (this.options.toleranceElement ? $(this.options.toleranceElement, t) : t).outerHeight(); 
     204                         
    197205                        var p = (this.options.toleranceElement ? $(this.options.toleranceElement, t) : t).offset(); 
    198206                        this.items[i].left = p.left; 
    199207                        this.items[i].top = p.top; 
    200                 }; 
     208                         
     209                }; 
     210                 
    201211                for (var i = this.containers.length - 1; i >= 0; i--){ 
    202212                        var p =this.containers[i].element.offset(); 
     
    206216                        this.containers[i].containerCache.height = this.containers[i].element.outerHeight(); 
    207217                }; 
     218                 
    208219        }, 
    209220        destroy: function() { 
     
    266277                                                } 
    267278                                                 
    268                                                  
    269                                                 itemWithLeastDistance ? this.rearrange(e, itemWithLeastDistance) : this.rearrange(e, null, this.containers[i].element); 
     279                                                this.currentContainer = this.containers[i]; 
     280                                                itemWithLeastDistance ? this.rearrange(e, itemWithLeastDistance, null, true) : this.rearrange(e, null, this.containers[i].element, true); 
    270281                                                this.propagate("change", e); //Call plugins and callbacks 
    271282                                                this.containers[i].propagate("change", e, this); //Call plugins and callbacks 
    272                                                 this.currentContainer = this.containers[i]; 
    273283 
    274284                                        } 
     
    519529                 
    520530        }, 
    521         rearrange: function(e, i, a) { 
     531        rearrange: function(e, i, a, hardRefresh) { 
    522532                a ? a.append(this.currentItem) : i.item[this.direction == 'down' ? 'before' : 'after'](this.currentItem); 
    523                 this.refreshPositions(true); //Precompute after each DOM insertion, NOT on mousemove 
     533                this.refreshPositions(!hardRefresh); //Precompute after each DOM insertion, NOT on mousemove 
    524534                if(this.options.placeholder) this.options.placeholder.update.call(this.element, this.currentItem, this.placeholder); 
    525535        },