我需要两个div(黄色方块)之间的线条。
屏幕:http://screencloud.net/v/5KlH
我想要这个:http://staraban.com/wp-content/uploads/2014/03/unreal-engine-4-blueprint-editor.jpg
点击黄色方块,id = 1,class = connect,点击黄色方块id = 2 class = connect。脚本创建行,beetwen id = 1和id = 2。
我的divs是可拖的
请帮忙。抱歉我的英文不好:)
我的小提琴:http://jsfiddle.net/ctwheels/f38bm9r8/
我的代码:
<head>
<title>Graphic Print</title>
<meta charset="utf-8">
<link rel="stylesheet" type="text/css" href="styles.css">
<script src="http://code.jquery.com/jquery-2.1.1.min.js"></script>
<script>
(function($) {
$.fn.drags = function(opt) {
opt = $.extend({handle:"",cursor:"move"}, opt);
if(opt.handle === "") {
var $el = this;
} else {
var $el = this.find(opt.handle);
}
return $el.css('cursor', opt.cursor).on("mousedown", function(e) {
if(opt.handle === "") {
var $drag = $(this).addClass('draggable');
} else {
var $drag = $(this).addClass('active-handle').parent().addClass('draggable');
}
var z_idx = $drag.css('z-index'),
drg_h = $drag.outerHeight(),
drg_w = $drag.outerWidth(),
pos_y = $drag.offset().top + drg_h - e.pageY,
pos_x = $drag.offset().left + drg_w - e.pageX;
$drag.css('z-index', 1000).parents().on("mousemove", function(e) {
$('.draggable').offset({
top:e.pageY + pos_y - drg_h,
left:e.pageX + pos_x - drg_w
}).on("mouseup", function() {
$(this).removeClass('draggable').css('z-index', z_idx);
});
});
e.preventDefault(); // disable selection
}).on("mouseup", function() {
if(opt.handle === "") {
$(this).removeClass('draggable');
} else {
$(this).removeClass('active-handle').parent().removeClass('draggable');
}
});
}
})(jQuery);
$(document).ready(function() {
$('.element').drags();
$('li').on( 'click', 'input', function () {
$(this).focus();
});
});
</script>
</head>
<body>
<div id="panel">
ddd
</div>
<section id="graphic">
<div style="top: 198px; left: 586px;" class="element">
<div class="title">Print string</div>
<div class="content">
<ul>
<li>Connect <div id="1" style="float:left" class="connect"></div></li>
<li><input type="text" value placeholder="Hello!"/></li>
</ul>
</div>
</div>
<div style="top: 245px; left: 45px;" class="element">
<div class="title">Start script</div>
<div class="content">
<ul>
<li>Connect <div id="2"class="connect"></div></li>
</ul>
</div>
</div>
</section>
</body>