我正在尝试增加图像放置区域的目标大小,以便当用户拖动它时,它们可以告诉它应该放置的位置,并且页面不会随机调整到被丢弃的图像那个drop得到图像的顺序列表。如何使目标更大并获取图像信息?图像上的信息可以只是源名称列表。
编辑:我想将一个项目拖动到框中,它会作为第一个项目上升并增加目标框的范围,以便用户可以放心地用正确的提示拖入框中。
var order;
var adjustment;
var group = $("ol.simple_with_animation").sortable({
group: 'simple_with_animation',
pullPlaceholder: false,
// animation on drop
onDrop: function($item, container, _super) {
var $clonedItem = $('<li/>').css({
height: 0
});
$item.before($clonedItem);
$clonedItem.animate({
'height': $item.height()
});
$item.animate($clonedItem.position(), function() {
$clonedItem.detach();
_super($item, container);
});
var data = group.sortable("serialize").get();
order = data[1];
console.log(order);
},
// set $item relative to cursor position
onDragStart: function($item, container, _super) {
var offset = $item.offset(),
pointer = container.rootGroup.pointer;
adjustment = {
left: pointer.left - offset.left,
top: pointer.top - offset.top
};
_super($item, container);
},
onDrag: function($item, position) {
$item.css({
left: position.left - adjustment.left,
top: position.top - adjustment.top
});
},
serialize: function(parent, children, isContainer) {
return isContainer ? children.join() : parent.text();
},
tolerance: 6,
distance: 10
});
body.dragging,
body.dragging * {
cursor: move !important;
}
.dragged {
position: absolute;
opacity: 0.5;
z-index: 2000;
}
ol.simple_with_animation li.placeholder {
position: relative;
/** More li styles **/
}
ol.simple_with_animation li.placeholder:before {
position: absolute;
/** Define arrowhead **/
}
#GamblerOrderSource,
#GamblerOrderTarget {
min-height: 50px;
margin: 0px 25px 10px 0px;
padding: 2px;
border-width: 1px;
border-style: solid;
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
border-radius: 3px;
list-style-type: none;
list-style-position: inside;
display: inline-block;
}
#GamblerOrderSource {
border: 2px dashed #f8e0b1 !important;
background-color: #fefcf5 !important;
}
#GamblerOrderTarget {
border: 2px dashed #add38d !important;
background-color: #f6fbf4 !important;
}
#GamblerOrderSource li {
background-color: #fcf8e3;
border: 1px solid #fbeed5;
color: #c09853;
}
#GamblerOrderTarget li {
background-color: #ebf5e6;
border: 1px solid #d6e9c6;
color: #468847;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-sortable/0.9.13/jquery-sortable-min.js"></script>
<form id="orderform" method='POST'>
<div id='GamblerOrderSource'>
<ol class='simple_with_animation'>
<li id="image_first"><img src="http://ec2-54-244-61-189.us-west-2.compute.amazonaws.com//static/DEAD.ICO"></li>
<li id="image_second"><img src="http://ec2-54-244-61-189.us-west-2.compute.amazonaws.com//static/DEAD.ICO"></li>
<li id="image_third"><img src="http://ec2-54-244-61-189.us-west-2.compute.amazonaws.com//static/DEAD.ICO"></li>
<li id="image_fourth"><img src="http://ec2-54-244-61-189.us-west-2.compute.amazonaws.com//static/DEAD.ICO"></li>
</ol>
</div>
<div id='GamblerOrderTarget'>
<ol class='simple_with_animation'>
</ol>
</div>
<input type="submit" value="Continue" />
</form>
答案 0 :(得分:0)
使用Jquery-sortable我只需将其修改为以下内容:
.dragged {
position: absolute;
opacity: 0.5;
z-index: 2000;
}
ol.simple_with_animation li.placeholder {
position: relative;
/** More li styles **/
font-size: 200%; /* or whatever */
}