$.widget('ui.fastSortable', $.extend({}, $.ui.mouse, { _init: function() { this._mouseInit(); }, _mouseCapture: function(e) { return e.target.id != 'sortable'; }, _mouseStart: function(e) { this.current = $(e.target); this.children = this.element.find('div'); this.helper = this.current.clone() .appendTo(this.element) .css({ position: 'absolute', top: e.pageY - 27, left: e.pageX - 27 }); this.current.addClass('sorting'); }, _mouseDrag: function(e) { //Move the helper with the mouse this.helper[0].style.top = (e.pageY - 27) + 'px'; this.helper[0].style.left = (e.pageX - 27) + 'px'; //Make your own calculations, hard coded var column = Math.min(20, Math.round((e.pageX) / 60)); var row = Math.round((e.pageY - 27) / 60); var index = (row * 20) + column; //Replace the element in the DOM this.element[0].insertBefore(this.current[0], this.children[index]); }, _mouseStop: function(e) { this.helper.remove(); this.current.removeClass('sorting'); } })); $.extend($.ui.fastSortable, { defaults: { distance: 1, delay: 0 } });