better image placing

master
Mark MacKay 2021-05-18 13:23:10 -05:00
parent 834e3e7f0e
commit 5070574728
2 changed files with 5 additions and 11 deletions

View File

@ -5534,7 +5534,6 @@ var uniquifyElems = this.uniquifyElems = function(g) {
// assign element its new id
elem.id = newid;
// remap all url() attributes
var attrs = ids[oldid]["attrs"];
var j = attrs.length;
@ -5542,9 +5541,9 @@ var uniquifyElems = this.uniquifyElems = function(g) {
var attr = attrs[j];
attr.ownerElement.setAttribute(attr.name, "url(#" + newid + ")");
}
// remap all href attributes
var hreffers = ids[oldid]["hrefs"];
console.log(hreffers)
var k = hreffers.length;
while (k--) {
var hreffer = hreffers[k];
@ -6059,15 +6058,9 @@ this.importSvgString = function(xmlString) {
canvash = +svgcontent.getAttribute("height");
// imported content should be 1/3 of the canvas on its largest dimension
if (innerh > innerw) {
var ts = "scale(" + (canvash/3)/vb[3] + ")";
}
else {
var ts = "scale(" + (canvash/3)/vb[2] + ")";
}
// Hack to make recalculateDimensions understand how to scale
ts = "translate(0) " + ts + " translate(0)";
var ts = "translate(0)";
var symbol = svgdoc.createElementNS(svgns, "symbol");
var defs = findDefs();

View File

@ -319,13 +319,14 @@ svgedit.utilities.getUrlFromAttr = function(attrVal) {
// Function: svgedit.utilities.getHref
// Returns the given element's xlink:href value
svgedit.utilities.getHref = function(elem) {
if (elem) return elem.getAttributeNS(XLINKNS, "href");
if (elem) return elem.getAttributeNS(XLINKNS, "href") || elem.getAttribute("href");
}
// Function: svgedit.utilities.setHref
// Sets the given element's xlink:href value
svgedit.utilities.setHref = function(elem, val) {
elem.setAttributeNS(XLINKNS, "xlink:href", val);
elem.setAttribute("href", val);
}
// Function: findDefs