From 5984c2643cc9b2fb11e0b6988f083411c482e751 Mon Sep 17 00:00:00 2001 From: Jeff Schiller Date: Thu, 22 Oct 2009 13:20:41 +0000 Subject: [PATCH] Minor improvement to mouse_target code git-svn-id: http://svg-edit.googlecode.com/svn/trunk@868 eee81c28-f429-11dd-99c0-75d572ba1ddd --- editor/svgcanvas.js | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/editor/svgcanvas.js b/editor/svgcanvas.js index 175edfef..aa5d088d 100644 --- a/editor/svgcanvas.js +++ b/editor/svgcanvas.js @@ -1538,12 +1538,11 @@ function BatchCommand(text) { // A (hopefully) quicker function to transform a point by a matrix // (this function avoids any DOM calls and just does the math) - // returns a tuple representing the transformed point + // Returns a x,y object representing the transformed point var transformPoint = function(x, y, m) { return { x: m.a * x + m.c * y + m.e, y: m.b * x + m.d * y + m.f}; }; - // in mouseDown : // - when we are in a create mode, the element is added to the canvas // but the action is not recorded until mousing up // - when we are in select mode, select the element, remember the position @@ -1575,11 +1574,11 @@ function BatchCommand(text) { // Webkit bubbles the mouse event all the way up to the div, so we // set the mouse_target to the svgroot like the other browsers if (mouse_target.nodeName.toLowerCase() == "div") { - mouse_target = document.getElementById("svgroot"); + mouse_target = svgroot; } // if it is a selector grip, then it must be a single element selected, // set the mouse_target to that - if (mouse_target.id.substr(0,13) == "selectorGroup" && selectedElements[0] != null) { + if (mouse_target.parentNode == selectorManager.selectorParentGroup && selectedElements[0] != null) { mouse_target = selectedElements[0]; } @@ -1587,8 +1586,7 @@ function BatchCommand(text) { case "select": started = true; current_resize_mode = "none"; - var nodeName = mouse_target.nodeName.toLowerCase(); - if (nodeName != "svg") { + if (mouse_target != svgroot) { // if this element is not yet selected, clear selection and select it if (selectedElements.indexOf(mouse_target) == -1) { // only clear selection if shift is not pressed (otherwise, add