简体   繁体   English

从一个可排序的jqueryui中获取项目时,禁用项目移动的动画

[英]Disable the animation of items moving when getting items from one jqueryui sortable to another

I want to have the sortable functionality within each sortable. 我想在每个可排序函数中都具有可排序函数。 Between two sortables, I want to move a draggable item onto a placeholder ie a droppable item. 在两个可排序项之间,我想将可拖动项移动到占位符(即可放置项)上。 I want it to seem as if the item falls onto the droppable. 我希望它看起来好像该项目落在可放置对象上。 Now, it should be sortable within this other sortable. 现在,它应该可以在其他可排序对象中进行排序。 For this reason, i have made all the sortable connected, and on drop on the placeholder, I removed that placeholder and added this dragged item. 出于这个原因,我将所有可排序对象都连接了起来,放下占位符后,我删除了该占位符并添加了此拖动项。

But, on hover of an item on any other sortable, it shows the animation of items moving around. 但是,将某项悬停在任何其他可排序项上时,它会显示出四处移动的项的动画。 I dont want that animation because there should ideally be no extra spaces available. 我不需要该动画,因为理想情况下应该没有可用的额外空间。 The item should only go on a droppable. 该物品只能放在可丢弃物品上。

Is it possible ? 可能吗 ? And how do I do it ? 我该怎么办?

Thanks 谢谢

Link to the fiddle I created is : http://jsfiddle.net/ZTu24/ 链接到我创建的小提琴是: http : //jsfiddle.net/ZTu24/

Code is as follow : 代码如下:

var rearrange = function (rowSelector) {

   var counter = 1;
   $("#" + rowSelector).children(".innerDiv").each(function () {
       $(this).children(":first").html(this.id + " " + counter++);
   });
}

$(function () {


   rearrange("row1");
   rearrange("row2");
   $(".innerDivPlaceholder").droppable({

       activeClass: "droppableHighlight",
       drop: function (event, ui) {

           alert("Dropped !!");
           var sourceRow = ui.helper.context.attributes[1].value; // to get value of token id
           var destinationRow = $(this).context.attributes[1].value; // to get value of token id
           sourceRow1 = new String(sourceRow);
           destinationRow1 = new String(destinationRow);

           //console.log(ui.helper.context);
           alert("Source Row = " + sourceRow1);
           alert("Destination Row = " + destinationRow1);
           if (sourceRow == destinationRow) {
               alert("Source equals destination");
               dropCancelled = true;
               return false;
           } else {
               $(this).remove();
           }
       }
   });
   $(".sortable").sortable({


       connectWith: ".sortable",
       revert: true,
       cancel: ".ui-state-disabled",
       //items : ".innerDiv:not(.innerDivPlaceholder)" ,


       stop: function (event, ui) {

           //$(".sortable").sortable( "enable" );
           var targetList = $(this);

           rearrange(targetList.context.id);

       }
   });
   $(".sortable").disableSelection();

   $(".sortable").on("sortreceive", function (event, ui) {


       var sourceList = ui.sender;
       var targetList = $(this);
       alert("In sortreceive ");
       //alert("Source id = " + sourceList.context.id);
       //alert("Target id = " + targetList.context.id);
       if ($(this).sortable('toArray').length > 3) {
           $(ui.sender).sortable('cancel');
       } else {

           var placeHolderDiv = document.createElement('div');

           placeHolderDiv.setAttribute("id", "placeholder100");
           placeHolderDiv.setAttribute("tokenid", sourceList.context.id);
           placeHolderDiv.setAttribute("class", "innerDivPlaceholder innerDiv ui-state-default ui-state-disabled floatLeftClass column3");


           //var innerPara1 = document.createElement('p');
           //innerPara1.textContent = "placeholder";
           //placeHolderDiv.appendChild(innerPara1);
           $(placeHolderDiv).droppable({

               activeClass: "droppableHighlight",
               drop: function (event, ui) {

                   alert("Dropped !!");
                   var sourceRow = ui.helper.context.attributes[1].value;
                   var destinationRow = $(this).context.attributes[1].value;
                   sourceRow1 = new String(sourceRow);
                   destinationRow1 = new String(destinationRow);


                   alert("Source Row = " + sourceRow1);
                   alert("Destination Row = " + destinationRow1);
                   if (sourceRow == destinationRow) {
                       alert("Source equals destination");
                       dropCancelled = true;
                       return false;
                   } else {
                       $(this).remove();
                   }
               }
           });

           $(placeHolderDiv).appendTo("#" + sourceList.context.id).sortable({

               connectWith: ".dottedDiv",
               revert: true,
               cancel: ".ui-state-disabled",
               //items : ".innerDiv:not(.innerDivPlaceholder)",
               stop: function (event, ui) {

                   //$(".sortable").sortable( "enable" );
                   var targetList = $(this);


                   rearrange(targetList.context.id);

               }
           }).disableSelection();


           rearrange(sourceList.context.id);
           rearrange(targetList.context.id);
           alert("Received !!");
       }
   });

   $(".dropDown").DropDown({


       menus: [{
           label: "Increase column span",
           action: "new",
           icon: 'print-icon'
       }, {
           label: "Decrease column span",
           action: "save",
           icon: 'print-icon' // classes: placing appropriate images at right place
       }],
       maxWidth: 100,
       groupLabel: 'File Hello',
       groupIcon: 'tick-icon',
       orientation: 'horizontal'
   });

});

I encountered just same problem as yours. 我遇到了和你一样的问题。 I set the placeholder as a dummy div tag to disable moving animation. 我将占位符设置为虚拟div标签以禁用移动动画。

$("#dragger").sortable({
    connectWith: "#dropper",
    placeholder: "<div></div>"
});

$("#dropper").sortable();

Maybe that can help for someone, set the placeholder height to zero for disable the moving animation. 可能对某人有帮助,请将占位符高度设置为零以禁用移动动画。

change:  function (event, ui) {
    $(ui.placeholder).height(0);
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何防止jQuery可排序项目从一个列表移动到另一个列表? - How to prevent jQuery sortable items moving from one list to another? 禁用 jQueryUI 中嵌套可排序项的拖动冒泡 - Disable drag bubbling for nested sortable items in jQueryUI 将项目从一个ListBox移至另一个,并在ListBox中获取项目 - Moving items from one ListBox to another and getting items in ListBox 使用jQueryUI对可排序列表中的项目进行分组 - Group items in a Sortable list with jQueryUI 尝试在列表中排序和放置项目时,jQueryUI可排序闪烁和跳转 - jQueryUI sortable flickering and jumping when trying to order and place items in the list 使用jQuery将项目从一个列表框移动到另一个列表框 - Moving items from one listbox to another using jquery jQuery基于组合框选择将项目从一个列表移动到另一个列表 - jQuery Moving Items from one list to another based on the combobox selection 通过jQuery将项目从一个列表框移动到另一个列表框 - Moving items from one listbox to another listbox through jquery jQuery-根据组合框选择将项目从一个列表移动到另一个列表 - Jquery - Moving Items from one list to another based on the combobox selection 在可排序的jquery-ui中移动元素时更改项目样式 - Change items style when moving elements in jquery-ui sortable
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM