Minor improvement to mouse_target code

git-svn-id: http://svg-edit.googlecode.com/svn/trunk@868 eee81c28-f429-11dd-99c0-75d572ba1ddd
master
Jeff Schiller 2009-10-22 13:20:41 +00:00
parent 04269414a9
commit 5984c2643c
1 changed files with 4 additions and 6 deletions

View File

@ -1538,12 +1538,11 @@ function BatchCommand(text) {
// A (hopefully) quicker function to transform a point by a matrix // A (hopefully) quicker function to transform a point by a matrix
// (this function avoids any DOM calls and just does the math) // (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) { 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}; 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 // - when we are in a create mode, the element is added to the canvas
// but the action is not recorded until mousing up // but the action is not recorded until mousing up
// - when we are in select mode, select the element, remember the position // - 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 // 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 // set the mouse_target to the svgroot like the other browsers
if (mouse_target.nodeName.toLowerCase() == "div") { 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, // if it is a selector grip, then it must be a single element selected,
// set the mouse_target to that // 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]; mouse_target = selectedElements[0];
} }
@ -1587,8 +1586,7 @@ function BatchCommand(text) {
case "select": case "select":
started = true; started = true;
current_resize_mode = "none"; current_resize_mode = "none";
var nodeName = mouse_target.nodeName.toLowerCase(); if (mouse_target != svgroot) {
if (nodeName != "svg") {
// if this element is not yet selected, clear selection and select it // if this element is not yet selected, clear selection and select it
if (selectedElements.indexOf(mouse_target) == -1) { if (selectedElements.indexOf(mouse_target) == -1) {
// only clear selection if shift is not pressed (otherwise, add // only clear selection if shift is not pressed (otherwise, add