As you can see in this example, jsferf calculating the outer width () / outerHeight () (this is what the plugin is - see below) for hidden elements (with no display) is horribly slower than for visible elements , since this is achieved by the attribute style or class.
The only way I found a workaround for this and still achieve the same result is to set the height for the elements to hide to zero , instead of working with the display property using the atttibute style or class:
<li style="height: 0;">b</li> <li class="hidden">b</li> .hidden { height: 0 }
DEMO (with class) - DEMO (with attr style)
What happens when sorting while dragging an item?
When you start a drag and drop, the plugin updates the list of all elements and recounts the positions of all elements. The plugin actually gets outerWidth and outerHeight:
_mouseStart: function(event, overrideHandle, noActivation) { ... //We only need to call refreshPositions, because the refreshItems call has been moved to mouseCapture this.refreshPositions(); ... } refreshPositions: function(fast) { ... for (var i = this.items.length - 1; i >= 0; i--) { var item = this.items[i]; ... if (!fast) { item.width = t.outerWidth(); item.height = t.outerHeight(); } var p = t.offset(); item.left = p.left; item.top = p.top; }; ... return this; },â
source share