我有两列,左边的一列是方形网格,浮动的,jQuery 可拖动元素。右边的列是一个 jQuery 放置目标。因此,当我在目标上放置一个 dropabble 时,它会附加到右侧列并隐藏在左侧,从而导致网格移动以填充该网格所在的空间。
有没有办法我可以使用 jQuery 而不是即时移动来制作动画?
好的,我添加了一些代码。我想说的是,如果你把绿色拖过去,左栏中后面的那些将移动以填充空白空间。我想知道他们自己做出的动作(离开后)是否可以动画化。抱歉,如果我感到困惑,不知道如何解释。
谢谢
如果有人有任何想法,最后一击。
<script type="text/javascript" src="jquery.min.js"></script>
<script src="jquery-ui-1.7.2.custom.min.js" type="text/javascript"></script>
<style>
.leftColumn{ width: 300px; height: 500px; outline: 2px solid blue; margin: 50px; float: left;}
.rightColumn{ width: 300px; height: 500px; outline: 2px solid green; margin: 50px; float: left;}
.gridElement{ width: 70px; height: 70px; outline: 2px solid purple; margin: 10px; float: left;}
</style>
<div class="leftColumn">
<div style="background-color: red;" class="gridElement"></div>
<div style="background-color: orange;" class="gridElement"></div>
<div style="background-color: yellow;" class="gridElement"></div>
<div style="background-color: green;" class="gridElement"></div>
<div style="background-color: blue;" class="gridElement"></div>
<div style="background-color: purple;" class="gridElement"></div>
<div style="background-color: gray;" class="gridElement"></div>
<div style="background-color: fuchsia;" class="gridElement"></div>
</div>
<div class="rightColumn"></div>
<script type="text/javascript">
$(document).ready(function() {
$(".gridElement").draggable({revert: "invalid", containment: "window", helper: "clone", appendTo: "body"});
$(".rightColumn").droppable({drop: function(event, ui) {
$(".rightColumn").append(ui.draggable);
ui.draggable.hide();
$(".rightColumn .gridElement").show();
}});
});
</script>