From 729900d796631e5e6ea26ca4ff88d9826bf57578 Mon Sep 17 00:00:00 2001 From: Jeff Schiller Date: Thu, 17 Dec 2009 15:12:54 +0000 Subject: [PATCH] fixtransforms branch: Remove zero-degree rotations and empty transform strings git-svn-id: http://svg-edit.googlecode.com/svn/branches/fixtransforms@1055 eee81c28-f429-11dd-99c0-75d572ba1ddd --- editor/svgcanvas.js | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/editor/svgcanvas.js b/editor/svgcanvas.js index e63896d2..1c698995 100644 --- a/editor/svgcanvas.js +++ b/editor/svgcanvas.js @@ -1550,7 +1550,10 @@ function BatchCommand(text) { } // if this element had no transforms, we are done - if (tlist.numberOfItems == 0) return null; + if (tlist.numberOfItems == 0) { + selected.removeAttribute("transform"); + return null; + } // we know we have some transforms, so set up return variable var batchCmd = new BatchCommand("Transform"); @@ -1797,9 +1800,14 @@ function BatchCommand(text) { // (this function has zero work to do for a rotate()) else { operation = 4; // rotation - var newRot = svgroot.createSVGTransform(); - newRot.setRotate(angle,newcenter.x,newcenter.y); - tlist.insertItemBefore(newRot, 0); + if (angle) { + var newRot = svgroot.createSVGTransform(); + newRot.setRotate(angle,newcenter.x,newcenter.y); + tlist.insertItemBefore(newRot, 0); + } + if (tlist.numberOfItems == 0) { + selected.removeAttribute("transform"); + } return null; } @@ -4109,7 +4117,7 @@ function BatchCommand(text) { addCommandToHistory(new InsertElementCommand(element)); call("changed",[element]); } - + start_transform = null; }; @@ -5238,10 +5246,15 @@ function BatchCommand(text) { } // find R_nc and insert it - var center = transformPoint(cx,cy,transformListToTransform(tlist).matrix); - var R_nc = svgroot.createSVGTransform(); - R_nc.setRotate(val, center.x, center.y); - tlist.insertItemBefore(R_nc,0); + if (val != 0) { + var center = transformPoint(cx,cy,transformListToTransform(tlist).matrix); + var R_nc = svgroot.createSVGTransform(); + R_nc.setRotate(val, center.x, center.y); + tlist.insertItemBefore(R_nc,0); + } + else if (tlist.numberOfItems == 0) { + elem.removeAttribute("transform"); + } if (!preventUndo) { // we need to undo it, then redo it so it can be undo-able! :)