d3675c18d020ec73b98f5d0ed83fa76e8c13fd6c tdreszer Tue May 31 20:09:36 2011 -0700 Fixed a problem where fast moves could scramble tracks not dragged. diff --git src/hg/js/jquery.tablednd.js src/hg/js/jquery.tablednd.js index 5fdb9ce..37e53cf 100644 --- src/hg/js/jquery.tablednd.js +++ src/hg/js/jquery.tablednd.js @@ -314,31 +314,40 @@ // effect dynamically var currentRow = jQuery.tableDnD.findDropTargetRow(dragObj, y); ////// UCSC if (config.dragObjects.length > 1) { if (movingDown) currentRow = jQuery.tableDnD.findDropTargetRow(config.dragObjects[config.dragObjects.length - 1], y + config.downOffset); else currentRow = jQuery.tableDnD.findDropTargetRow(config.dragObjects[0], y + config.upOffset); } ////// UCSC if (currentRow) { ////// UCSC if (config.dragObjects.length > 1) { if (movingDown && config.dragObjects[config.dragObjects.length - 1] != currentRow) { try { // use try/catch because sometimes rows go missing when moving down + // can't just insert currentRow above, because there may be more than one row that needs to move up + //$( currentRow ).insertBefore( $( config.dragObjects[0] ) ); + var curRowIx = $( currentRow ).attr('rowIndex'); + if (curRowIx == (jQuery.tableDnD.currentTable.rows.length - 1)) { + // Even though this is method is bad on fast drags, + // getting to the end seems to only work on slow moves anyway. + // plus numerous other strateges failed to get this to work at all. $( currentRow ).insertBefore( $( config.dragObjects[0] ) ); + } else + $(config.dragObjects).insertBefore( $(currentRow).next() ); jQuery.tableDnD.oldY = y; } catch (err) { // just put them all back for(var ix=0;ix < config.dragObjects.length; ix++) { $(config.dragObjects[ix]).insertBefore( currentRow ); } } } else if (!movingDown && config.dragObjects[0] != currentRow) { $(config.dragObjects).insertBefore( currentRow ); jQuery.tableDnD.oldY = y; } } else { ////// UCSC // TODO worry about what happens when there are multiple TBODIES if (movingDown && jQuery.tableDnD.dragObject != currentRow) {