我已经创建了我的脚本外观的小提琴:https ://jsfiddle.net/xpvt214o/701253/
这是我的代码:
HTML:
<div id="_idContainer011" class="tabcontent" data-layer-id="35" data-locked="0" style="position: absolute; width: 107.012px; height: 106.273px;" data-x="-0.48828125" data-y="6.15234375">
<img class="_idGenObjectAttribute-1 _idGenObjectAttribute-2" src="https://redbutton.nl/static/img/mieps/miep_hanging.png" alt="">
<div class="resize-handle-container" id="handle-_idContainer011" style="width: 147px; height: 146.266px;">
<div class="handle handle-left-top" id="handle-_idContainer011-left-top"></div>
<div class="handle handle-right-top" id="handle-_idContainer011-right-top"></div>
<div class="handle handle-left-bottom" id="handle-_idContainer011-left-bottom"></div>
<div class="handle handle-right-bottom" id="handle-_idContainer011-right-bottom"></div>
<div class="handle handle-rotate" id="handle-_idContainer011-rotate"></div>
</div>
</div>
JS:
var target = $('#_idContainer011');
interact('#_idContainer011')
.styleCursor(false)
.draggable({
manualStart: false,
allowFrom: '.handle-rotate',
onstart: function (event) {
console.log('onstart');
},
onmove: function (event) {
console.log('onmove');
},
onend: function (event) {
console.log('onend');
},
});
interact('#_idContainer011')
.styleCursor(false)
.resizable({
manualStart: true,
edges: {
left: true,
right: true,
bottom: true,
top: true
}
})
.on('resizemove', function (event) {
console.log('resizemove');
});
/**
* Resizing element
*/
interact('.resize-handle-container .handle:not(.handle-rotate)').on('down', function (event) {
let interaction = event.interaction,
handle = $(event.currentTarget);
interaction.start({
name: 'resize',
edges: {
top: handle.data('top'),
left: handle.data('left'),
bottom: handle.data('bottom'),
right: handle.data('right'),
}
},
interact('#_idContainer011'), // target Interactable
target[0] // target Element
);
});
我对单个元素具有可拖动和可调整大小。调整大小工作完美,但可拖动并没有做任何事情。它们都使用不同的手柄。当我禁用调整大小时,draggable 也会恢复活力,但一旦我启用调整大小,draggable 就会再次死亡(https://jsfiddle.net/xpvt214o/701281/)。
问题可能是什么?