marina_chazova,
нажать на блок и тянуть стрелку до нужного места ...
<!DOCTYPE HTML>
<html>
<head>
<title>Untitled</title>
<meta charset="utf-8">
<style type="text/css">
body{
position: relative;
height: 500px;
}
hr.connection{
position: absolute;
width: 0px;
height: 1px;
background-color: #FFFF00;
padding: 0;
margin: 0;
z-index: 2;
}
hr.connection:after {
content: "";
display: block;
position: absolute;
width: 0;
height: 0;
border: 40px solid transparent;
border-right: 0;
top: -12px;
right: -4px;
border-left-color: #0000FF;
border-width: 12px 0 12px 60px;
}
.one {
background-color: #FFD700;
position: absolute;
width: 50px;
height: 50px;
border-radius: 8px;
border: 4px solid #8B4513;
}
.two{
border-radius: 8px;
border: 6px solid #006400;
position: absolute;
top: 30%;
left: 50%;
background-color: #228B22;
z-index: 1;
width: 128px;
height: 128px;
}
</style>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<script>
(function($) {
$.fn.connectionItem = function(options) {
var defaults = {};
var settings = $.extend({}, defaults, options);
return this.each(function(i, el) {
var from = $(el);
function cl(event) {
event.preventDefault();
var x0, y0;
var x, y, x1, y1, r;
var pos = from.offset();
x0 = pos.left + from.width() / 2;
y0 = pos.top + from.height() /
2;
var hr = $("<hr/>", {
"class": "connection",
css: {
position: "absolute",
left: x0,
top: y0,
}
}).appendTo("body");
hr.css("transform-origin", 0);
hr.css("-moz-transform-origin", 0);
hr.css("-webkit-transform-origin", 0);
hr.css("-o-transform-origin", 0);
function fn(event) {
event.preventDefault();
x1 = event.pageX;
y1 = event.pageY;
x = x1 - x0;
y = y1 - y0;
var w = Math.sqrt(x * x + y * y);
r = 360 - 180 / Math.PI * Math.atan2(y, x);
hr.css({
width: w
});
hr.css("transform", "rotate(-" + r + "deg)");
hr.css("-moz-transform", "rotate(-" + r + "deg)");
hr.css("-webkit-transform", "rotate(-" + r + "deg)");
hr.css("-o-transform", "rotate(-" + r + "deg)")
}
$(window).on({
mousemove: fn,
mouseup: function() {
$(window).off("mousemove", fn)
}
})
}
from.on({
mousedown: cl
})
})
}
})(jQuery);
$(function(){
function rand(a) {
return 5 + Math.floor(Math.random() * a)
}
$.each(Array(12),function(indx, element){
$('<div>',{css : {top : rand(80)+"%",left : rand(80)+"%"} , "class" : "one"})
.appendTo('body')
});
$(".one").connectionItem();//
});
</script>
</head>
<body >
</body>
</html>