Remove element if mouse has not moved.

git-svn-id: http://svg-edit.googlecode.com/svn/trunk@2521 eee81c28-f429-11dd-99c0-75d572ba1ddd
This commit is contained in:
Ben McDonald
2013-06-30 13:15:10 +00:00
parent 089f061641
commit 3b9b729194

View File

@@ -73,6 +73,7 @@ svgEditor.addExtension('shapes', function() {
var cur_lib = library.basic; var cur_lib = library.basic;
var mode_id = 'shapelib'; var mode_id = 'shapelib';
var startClientPos = {};
function loadIcons() { function loadIcons() {
$('#shape_buttons').empty().append(cur_lib.buttons); $('#shape_buttons').empty().append(cur_lib.buttons);
@@ -244,6 +245,9 @@ svgEditor.addExtension('shapes', function() {
var y = start_y = opts.start_y; var y = start_y = opts.start_y;
var cur_style = canv.getStyle(); var cur_style = canv.getStyle();
startClientPos.x = opts.event.clientX;
startClientPos.y = opts.event.clientY;
cur_shape = canv.addSvgElementFromJson({ cur_shape = canv.addSvgElementFromJson({
'element': 'path', 'element': 'path',
'curStyles': true, 'curStyles': true,
@@ -335,16 +339,11 @@ svgEditor.addExtension('shapes', function() {
mouseUp: function(opts) { mouseUp: function(opts) {
var mode = canv.getMode(); var mode = canv.getMode();
if (mode !== mode_id) return; if (mode !== mode_id) return;
if (opts.mouse_x == start_x && opts.mouse_y == start_y) {
return { var keepObject = (opts.event.clientX != startClientPos.x && opts.event.clientY != startClientPos.y);
keep: false,
element: cur_shape,
started: false
};
}
return { return {
keep: true, keep: keepObject,
element: cur_shape, element: cur_shape,
started: false started: false
}; };