JS optimization in svgcanvas.js

git-svn-id: http://svg-edit.googlecode.com/svn/trunk@458 eee81c28-f429-11dd-99c0-75d572ba1ddd
This commit is contained in:
Alexis Deveria
2009-08-24 18:39:22 +00:00
parent d27fcf1da9
commit 13fc0f5d08

View File

@@ -275,27 +275,27 @@ function SvgCanvas(c)
var bbox = cur_bbox || canvas.getBBox(this.selectedElement); var bbox = cur_bbox || canvas.getBBox(this.selectedElement);
// console.log({'cur_bbox':cur_bbox, 'bbox':bbox }); // console.log({'cur_bbox':cur_bbox, 'bbox':bbox });
var l=bbox.x-offset, t=bbox.y-offset, w=bbox.width+(offset<<1), h=bbox.height+(offset<<1); var l=bbox.x-offset, t=bbox.y-offset, w=bbox.width+(offset<<1), h=bbox.height+(offset<<1);
// TODO: use suspendRedraw() here assignAttributes(selectedBox, {
selectedBox.setAttribute("x", l); 'x': l,
selectedBox.setAttribute("y", t); 'y': t,
selectedBox.setAttribute("width", w); 'width': w,
selectedBox.setAttribute("height", h); 'height': h
selectedGrips.nw.setAttribute("x", l-3); });
selectedGrips.nw.setAttribute("y", t-3); var gripCoords = {
selectedGrips.ne.setAttribute("x", l+w-3); nw: [l-3, t-3],
selectedGrips.ne.setAttribute("y", t-3); ne: [l+w-3, t-3],
selectedGrips.sw.setAttribute("x", l-3); sw: [l-3, t+h-3],
selectedGrips.sw.setAttribute("y", t+h-3); se: [l+w-3, t+h-3],
selectedGrips.se.setAttribute("x", l+w-3); n: [l+w/2-3, t-3],
selectedGrips.se.setAttribute("y", t+h-3); w: [l-3, t+h/2-3],
selectedGrips.n.setAttribute("x", l+w/2-3); e: [l+w-3, t+h/2-3],
selectedGrips.n.setAttribute("y", t-3); s: [l+w/2-3, t+h-3]
selectedGrips.w.setAttribute("x", l-3); };
selectedGrips.w.setAttribute("y", t+h/2-3); $.each(gripCoords, function(dir, coords) {
selectedGrips.e.setAttribute("x", l+w-3); assignAttributes(selectedGrips[dir], {
selectedGrips.e.setAttribute("y", t+h/2-3); x: coords[0], y: coords[1]
selectedGrips.s.setAttribute("x", l+w/2-3); });
selectedGrips.s.setAttribute("y", t+h-3); });
// empty out the transform attribute // empty out the transform attribute
this.selectorGroup.setAttribute("transform", ""); this.selectorGroup.setAttribute("transform", "");
@@ -1262,11 +1262,13 @@ function SvgCanvas(c)
if (rubberBox == null) { if (rubberBox == null) {
rubberBox = selectorManager.getRubberBandBox(); rubberBox = selectorManager.getRubberBandBox();
} }
rubberBox.setAttribute("x", start_x); assignAttributes(rubberBox, {
rubberBox.setAttribute("y", start_y); 'x': start_x,
rubberBox.setAttribute("width", 0); 'y': start_y,
rubberBox.setAttribute("height", 0); 'width': 0,
rubberBox.setAttribute("display", "inline"); 'height': 0,
'display': 'inline'
});
} }
break; break;