jQuery resize() event is not working while draggable

两盒软妹~` 提交于 2019-12-13 02:53:24

问题


I am trying to use jQuery to make "Draggable" into the DIV(id=sortable), but it's not working "Resize".

  1. Draggable "Drag me down" DIV into DIV(id=sortable)
  2. Draggable is working fine within the DIV(id=sortable)
  1. Resizable is not working within the DIV(id=sortable)

Does anyone know what I am doing wrong?

Script and HTML

$(function() {
  $("#sortable").sortable({
    revert: true
  });
  $("#draggable").draggable({
    connectToSortable: "#sortable",
    helper: "clone",
    revert: "invalid"
  });

  $('.resizemove').resizable();

});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div>
  <div id="draggable" class="ui-state-highlight ui-state-default resizemove DivStyle" style="width:100px; height:100px; display:block; background: lightyellow;">Drag me down</div><br>
</div>

<div id="sortable" class="main-wrap" style="border:5px solid rgb(221, 221, 221);padding: 5px; clear: both;">
  <div class="ui-state-default resizemove DivStyle" style="width:100px; height:100px; display:block; background: lightbluered;">One</div>
  <div class="ui-state-default resizemove DivStyle" style="width:100px; height:100px; display:block; background: lightpink;">Two</div>
  <div class="ui-state-default resizemove DivStyle" style="width:100px; height:100px; display:block; background: lightgray;">Three</div>
  <div class="ui-state-default resizemove DivStyle" style="width:100px; height:100px; display:block; background: lightseagreen;">Four</div>
  <div style="clear:both"></div>
</div>

Here is the JsFiddle


回答1:


I would adjust your Draggable Handle. For example:

  $("#draggable").draggable({
    connectToSortable: "#sortable",
    handle: $(this).not(".ui-resizable-handle"),
    helper: "clone",
    revert: "invalid"
  });

Example: https://jsfiddle.net/Twisty/84cvchas/2/



来源:https://stackoverflow.com/questions/48557144/jquery-resize-event-is-not-working-while-draggable

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!