jsPlumb 컨테이너를 드래그 가능하게 만들 수 있는지 알고 싶습니다. 컨테이너 (요소가 아님)를 클릭하고 드래그하면이 컨테이너의 다른 부분이나 요소에 집중할 수있는 단위로 이동합니다.
예를 들어 웹 페이지의 예제와 같은 순서도; http://www.jsplumb.org/demo/flowchart/jquery.html 그리고 클릭하고 드래그하면 전체 컨테이너가 이동하여 내부의 모든 요소도 이동합니다.
감사.
이 예를 가지고 놀 수 있습니다 . 먼저 새 컨테이너 버튼을 누른 다음 컨테이너 내부의 새 셀을 누릅니다. 컨테이너와 그 안의 셀을 드래그 할 수 있습니다.
자바 스크립트 :
var instanceRegistry = [];
var containerRegistry = [];
var cellRegistry = [];
$(function() {
var endpointOptions = {
isSource: true,
isTarget: true
};
$('#newContainerButton').click(newContainer);
$('#newCellButton').click(newCell);
function newContainer() {
var containerIndex = "container" + (containerRegistry.length + 1);
$('#containerTemplate').clone().appendTo('#mainContainer')
.show()
.attr('id', containerIndex)
.draggable({
containment: 'mainContainer',
cursor: 'move'
})
.find('.newCellButton').click(newCell).end();
containerRegistry.push(containerIndex);
var containerInstance = jsPlumb.getInstance({
Container: containerIndex,
Endpoint: [ // The default Endpoint definition.
'Dot', // Endpoint type
{ // Endpoint type options
radius: 6, // Defines the radius of the dot
cssClass: 'cell-endpoint' // A CSS class to attach to the element the Endpoint creates
}
],
PaintStyle: { // The default appearance of a Connector
strokeStyle: '#2e6f9a', // color for a Connector
lineWidth: 2 // width of a Connector's line
}
});
instanceRegistry.push(containerInstance);
}
function newCell(event) {
var $container = $(event.target).parent();
var cellIndex = "cell" + (cellRegistry.length + 1);
$('#cellTemplate').clone().appendTo($container)
.show()
.attr('id', cellIndex);
cellRegistry.push(cellIndex);
var num = containerRegistry.indexOf($container.attr('id'));
var instance = instanceRegistry[num];
instance.draggable(cellIndex, {
containment: $container,
cursor: 'move'
});
instance.addEndpoint(cellIndex, {anchor: "Top"}, endpointOptions);
instance.addEndpoint(cellIndex, {anchor: "Right"}, endpointOptions);
instance.addEndpoint(cellIndex, {anchor: "Bottom"}, endpointOptions);
instance.addEndpoint(cellIndex, {anchor: "Left"}, endpointOptions);
}
});
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다