Fix for use getBBox()

master
Dmitry Baranovskiy 2014-05-20 18:22:26 +10:00
parent 1bbd8e9fdd
commit c1e8a98db9
5 changed files with 878 additions and 61 deletions

File diff suppressed because one or more lines are too long

14
dist/snap.svg.js vendored
View File

@ -14,7 +14,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//
// build: 2014-05-16
// build: 2014-05-20
// Copyright (c) 2013 Adobe Systems Incorporated. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
@ -2043,16 +2043,20 @@ function arrayFirstValue(arr) {
o }
\*/
elproto.getBBox = function (isWithoutTransform) {
var el = this;
var el = this,
m = new Snap.Matrix;
if (el.removed) {
return {};
}
if (el.type == "use") {
while (el.type == "use") {
if (!isWithoutTransform) {
m = m.add(el.transform().localMatrix.translate(el.attr("x") || 0, el.attr("y") || 0));
}
if (el.original) {
el = el.original;
} else {
var href = el.attr("xlink:href");
el = el.node.ownerDocument.getElementById(href.substring(href.indexOf("#") + 1));
el = el.original = el.node.ownerDocument.getElementById(href.substring(href.indexOf("#") + 1));
}
}
var _ = el._;
@ -2062,7 +2066,7 @@ function arrayFirstValue(arr) {
} else {
el.realPath = (Snap.path.get[el.type] || Snap.path.get.deflt)(el);
el.matrix = el.transform().localMatrix;
_.bbox = Snap.path.getBBox(Snap.path.map(el.realPath, el.matrix));
_.bbox = Snap.path.getBBox(Snap.path.map(el.realPath, m.add(el.matrix)));
}
return Snap._.box(_.bbox);
};

File diff suppressed because it is too large Load Diff

19
dr.json
View File

@ -4,27 +4,30 @@
"template": "template.dot",
"files": [{
"url": "src/svg.js",
"link": "https://github.com/adobe-webplatform/savage/blob/master/src/svg.js"
"link": "https://github.com/adobe-webplatform/Snap.svg/blob/master/src/svg.js"
}, {
"url": "src/matrix.js",
"link": "https://github.com/adobe-webplatform/Snap.svg/blob/master/src/matrix.js"
}, {
"url": "src/paper.js",
"link": "https://github.com/adobe-webplatform/savage/blob/master/src/paper.js"
"link": "https://github.com/adobe-webplatform/Snap.svg/blob/master/src/paper.js"
}, {
"url": "src/equal.js",
"link": "https://github.com/adobe-webplatform/savage/blob/master/src/equal.js"
"link": "https://github.com/adobe-webplatform/Snap.svg/blob/master/src/equal.js"
}, {
"url": "src/mina.js",
"link": "https://github.com/adobe-webplatform/savage/blob/master/src/mina.js"
"link": "https://github.com/adobe-webplatform/Snap.svg/blob/master/src/mina.js"
}, {
"url": "src/filter.js",
"link": "https://github.com/adobe-webplatform/savage/blob/master/src/filter.js"
"link": "https://github.com/adobe-webplatform/Snap.svg/blob/master/src/filter.js"
}, {
"url": "src/mouse.js",
"link": "https://github.com/adobe-webplatform/savage/blob/master/src/mouse.js"
"link": "https://github.com/adobe-webplatform/Snap.svg/blob/master/src/mouse.js"
}, {
"url": "src/path.js",
"link": "https://github.com/adobe-webplatform/savage/blob/master/src/path.js"
"link": "https://github.com/adobe-webplatform/Snap.svg/blob/master/src/path.js"
}, {
"url": "src/set.js",
"link": "https://github.com/adobe-webplatform/savage/blob/master/src/set.js"
"link": "https://github.com/adobe-webplatform/Snap.svg/blob/master/src/set.js"
}]
}

View File

@ -1285,16 +1285,20 @@ function arrayFirstValue(arr) {
o }
\*/
elproto.getBBox = function (isWithoutTransform) {
var el = this;
var el = this,
m = new Snap.Matrix;
if (el.removed) {
return {};
}
if (el.type == "use") {
while (el.type == "use") {
if (!isWithoutTransform) {
m = m.add(el.transform().localMatrix.translate(el.attr("x") || 0, el.attr("y") || 0));
}
if (el.original) {
el = el.original;
} else {
var href = el.attr("xlink:href");
el = el.node.ownerDocument.getElementById(href.substring(href.indexOf("#") + 1));
el = el.original = el.node.ownerDocument.getElementById(href.substring(href.indexOf("#") + 1));
}
}
var _ = el._;
@ -1304,7 +1308,7 @@ function arrayFirstValue(arr) {
} else {
el.realPath = (Snap.path.get[el.type] || Snap.path.get.deflt)(el);
el.matrix = el.transform().localMatrix;
_.bbox = Snap.path.getBBox(Snap.path.map(el.realPath, el.matrix));
_.bbox = Snap.path.getBBox(Snap.path.map(el.realPath, m.add(el.matrix)));
}
return Snap._.box(_.bbox);
};