【问题标题】:When I make a draggable clone how to retain the height and width of the element当我制作可拖动克隆时如何保留元素的高度和宽度
【发布时间】:2016-05-09 23:57:20
【问题描述】:
$("li", $taskList).draggable({
helper : "clone",
revert : "invalid"
});
在拖动元素时,我希望保持相同的高度和宽度。
【问题讨论】:
标签:
javascript
jquery
html
drag-and-drop
angular-ui-bootstrap
【解决方案1】:
只是建立在 Prasad 的回答之上 - 保持原始项目的宽度和高度:
$(el).draggable({
helper: 'clone',
start: function (event, ui) {
var w = $(this).css('width');
var h = $(this).css('height');
ui.helper.css('width', w).css('height', h);
}
});
(编辑增加高度)
【解决方案2】:
$("li", $taskList).draggable({
helper: 'clone',
start: function (e, ui) {
ui.helper.animate({
width: 80,
height: 50
});
}
});
这对我有用。拖动时我们可以设置曲线的高度和宽度。