1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
|
move_ = 0;
$("#temp").css('display' , 'block');
dashArray = '5';
line = sketchpad.line(0,0,0,0,{fill:"red",role:"dragshape",stroke:"red",strokeWidth:1, strokeDashArray:dashArray, id:'temp'});
$('#svgsketch').mousedown( function(event){
event.preventDefault();
event = event.target;
cx = event.getAttribute('cx');
cy = event.getAttribute('cy');
group = event.parentNode.getAttribute('id');
$('#line1').html(cx);
$('#line2').html(cy);
$('#temp').css('display' , 'block');
xCon = $('circle').attr('cx');
$('#svgsketch').bind('mousemove' , mousemove);
$('#svgsketch').bind('mouseup' , mouseup);
});
var mouseup= function(event){
$('#temp').css('display' , 'none');
dashArray = '0'
event.preventDefault();
event = event.target;
cx = event.getAttribute('cx');
cy = event.getAttribute('cy');
group = event.parentNode.getAttribute('id');
$('#line3').html(cx);
$('#line4').html(cy);
$('#svgsketch').unbind('mousemove' , mousemove);
sketchpad.line($("#"+group), $('#line1').html(),$('#line2').html(),$('#line3').html(),$('#line4').html(),{fill:"red",role:"dragshape",stroke:"red",strokeWidth:1,strokeDashArray:dashArray});
x1 = line.getAttribute('x1');
x2 = line.getAttribute('x2');
y1 = line.getAttribute('y1');
y2 = line.getAttribute('y2');
valueX1 = (parseInt(x2) + parseInt(x1)) / 2 ;
valueY1 = (parseInt(y2) + parseInt(y1)) / 2 ;
valueX2 = parseInt(valueX1) - 5;
valueY2 = parseInt(valueY1) - 10;
valueX2bis = parseInt(valueX1) - 10;
valueY2bis = parseInt(valueY1) + 5;
$('#temp').css('display' , 'none');
};
var mousemove = function(event){
$("#temp").css('display' , 'block');
var destinationX = parseInt(event.pageX) - parseInt($('#svgsketch').offset().left);
var destinationY = parseInt(event.pageY) - parseInt($('#svgsketch').offset().top);
sketchpad.change(line, {x1:$('#line1').html(), y1:$('#line2').html(), x2:destinationX, y2:destinationY});
}; |
Partager