我实现了Jquery UI draggable,droppable,selectable和resizable。我的可拖动实现:
Draggable: {
init: function(el, options) {
$(el).draggable(options, {
scroll: false,
snap: '.gridlines',
snapTolerance: $('.grid').attr('data-size') / 2,
containment: "parent",
preventCollision : true,
preventProtrusion : false,
collisionVisualDebug : false
});
}
组件css:
.component{
border:solid 1px #a0a0a0;
background: #a6cbf7; /* Old browsers */
background: -moz-linear-gradient(top, #a6cbf7 0%, #defdfd 51%, #a6cbf7 100%); /* FF3.6-15 */
background: -webkit-linear-gradient(top, #a6cbf7 0%,#defdfd 51%,#a6cbf7 100%); /* Chrome10-25,Safari5.1-6 */
background: linear-gradient(to bottom, #a6cbf7 0%,#defdfd 51%,#a6cbf7 100%); /* W3C, IE10+, FF16+, Chrome26+, Opera12+, Safari7+ */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#a6cbf7', endColorstr='#a6cbf7',GradientType=0 ); /* IE6-9 */
text-align:center;
}
例如,如果我的父母的宽度为100px,高度为50px,我将孩子调到底部,我可以获得的最大顶部位置是48px或有时47px,右侧是97px或98px。根据我的例子,我怎么能得到49px或50px的最高值并留下99px或100px?