Commit 77636f06 by Dmitry Baranovskiy

0.5.12 Quick fix for patterns as well as fix for Safari & Opera.

parent 8b348280
/* /*
* Raphael 0.5.11 - JavaScript Vector Library * Raphael 0.5.12 - JavaScript Vector Library
* *
* Copyright (c) 2008 Dmitry Baranovskiy (raphaeljs.com) * Copyright (c) 2008 Dmitry Baranovskiy (http://raphaeljs.com)
* Licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) license. * Licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) license.
*/ */
var Raphael = (function (type) { var Raphael = (function (type) {
var r = function () { var r = function () {
return r._create.apply(r, arguments); return r._create.apply(r, arguments);
}; };
r.version = "0.5.11"; r.version = "0.5.12";
r.type = type; r.type = type;
var C = {}; var C = {};
function Matrix(m11, m12, m21, m22, dx, dy) { function Matrix(m11, m12, m21, m22, dx, dy) {
...@@ -984,6 +984,12 @@ var Raphael = (function (type) { ...@@ -984,6 +984,12 @@ var Raphael = (function (type) {
}; };
o.setAttribute("fill", "url(#" + el.id + ")"); o.setAttribute("fill", "url(#" + el.id + ")");
}; };
var updatePosition = function (o) {
if (o.pattern) {
var bbox = o.node.getBBox();
o.pattern.setAttribute("patternTransform", "translate(" + [bbox.x, bbox.y].join(",") + ")");
}
};
var setFillAndStroke = function (o, params) { var setFillAndStroke = function (o, params) {
var dasharray = { var dasharray = {
"-": [3, 1], "-": [3, 1],
...@@ -1005,11 +1011,13 @@ var Raphael = (function (type) { ...@@ -1005,11 +1011,13 @@ var Raphael = (function (type) {
case "cx": case "cx":
case "x": case "x":
o[0].setAttribute(att, o.svg._getX(value)); o[0].setAttribute(att, o.svg._getX(value));
updatePosition(o);
break; break;
case "ry": case "ry":
case "cy": case "cy":
case "y": case "y":
o[0].setAttribute(att, o.svg._getY(value)); o[0].setAttribute(att, o.svg._getY(value));
updatePosition(o);
break; break;
case "width": case "width":
o[0].setAttribute(att, o.svg._getW(value)); o[0].setAttribute(att, o.svg._getW(value));
...@@ -1044,7 +1052,6 @@ var Raphael = (function (type) { ...@@ -1044,7 +1052,6 @@ var Raphael = (function (type) {
if (isURL) { if (isURL) {
var el = document.createElementNS(o.svg.svgns, "pattern"); var el = document.createElementNS(o.svg.svgns, "pattern");
var ig = document.createElementNS(o.svg.svgns, "image"); var ig = document.createElementNS(o.svg.svgns, "image");
console.log(isURL);
el.id = "raphael-pattern-" + o.svg.gradients++; el.id = "raphael-pattern-" + o.svg.gradients++;
el.setAttribute("x", 0); el.setAttribute("x", 0);
el.setAttribute("y", 0); el.setAttribute("y", 0);
...@@ -1053,8 +1060,8 @@ var Raphael = (function (type) { ...@@ -1053,8 +1060,8 @@ var Raphael = (function (type) {
ig.setAttribute("y", 0); ig.setAttribute("y", 0);
ig.setAttributeNS(o.svg.xlink, "href", isURL[1]); ig.setAttributeNS(o.svg.xlink, "href", isURL[1]);
el.appendChild(ig); el.appendChild(ig);
var img = document.createElement("img"); var img = document.createElement("img");
img.src = isURL[1];
img.style.position = "absolute"; img.style.position = "absolute";
img.style.top = "-9999em"; img.style.top = "-9999em";
img.style.left = "-9999em"; img.style.left = "-9999em";
...@@ -1066,9 +1073,13 @@ var Raphael = (function (type) { ...@@ -1066,9 +1073,13 @@ var Raphael = (function (type) {
document.body.removeChild(this); document.body.removeChild(this);
}; };
document.body.appendChild(img); document.body.appendChild(img);
img.src = isURL[1];
o.svg.defs.appendChild(el); o.svg.defs.appendChild(el);
o[0].style.fill = "url(#" + el.id + ")"; o[0].style.fill = "url(#" + el.id + ")";
o[0].setAttribute("fill", "url(#" + el.id + ")"); o[0].setAttribute("fill", "url(#" + el.id + ")");
o.pattern = el;
updatePosition(o);
C.safari();
break; break;
} }
default : default :
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment