Skip to content
Browse files

1.4.6 Hot fix for broken getLength method. Also fixed safari method (…

…removed black frame bug)
  • Loading branch information...
1 parent 8aa6a57 commit fa3418b91c5c78f9fe761c8f55f39e0213fa4388 @DmitryBaranovskiy committed Jul 9, 2010
Showing with 116 additions and 118 deletions.
  1. +101 −101 raphael-min.js
  2. +15 −17 raphael.js
View
202 raphael-min.js
101 additions, 101 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
View
32 raphael.js
@@ -1,5 +1,5 @@
/*!
- * Raphael 1.4.5 - JavaScript Vector Library
+ * Raphael 1.4.6 - JavaScript Vector Library
*
* Copyright (c) 2010 Dmitry Baranovskiy (http://raphaeljs.com)
* Licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) license.
@@ -19,7 +19,7 @@ Raphael = (function () {
}
return create[apply](R, arguments);
}
- R.version = "1.4.5";
+ R.version = "1.4.6";
var separator = /[, ]+/,
elements = /^(circle|rect|path|ellipse|text|image)$/,
proto = "prototype",
@@ -2467,10 +2467,10 @@ Raphael = (function () {
}
// rest
- // Safari or Chrome (WebKit) rendering bug workaround method
- if ((/^Apple|^Google/).test(win.navigator.vendor) && (!(win.navigator.userAgent.indexOf("Version/4.0") + 1) || win.navigator.platform.slice(0, 2) == "iP")) {
+ // WebKit rendering bug workaround method
+ if ((navigator.vendor == "Apple Computer, Inc.") && (navigator.userAgent.match(/Version\/(.*?)\s/)[1] < 4 || win.navigator.platform.slice(0, 2) == "iP")) {

Fails under Linux webkit-gtk based browsers.

See possible fix in http://github.com/gentooboontoo/raphael/commit/52da362fdeee03dc55dd0f27edb7f893584a5806

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Paper[proto].safari = function () {
- var rect = this.rect(-99, -99, this.width + 99, this.height + 99);
+ var rect = this.rect(-99, -99, this.width + 99, this.height + 99).attr({stroke: "none"});
win.setTimeout(function () {rect.remove();});
};
} else {
@@ -2848,16 +2848,14 @@ Raphael = (function () {
};
},
segmentLength = cacher(function (p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y) {
- var a = (p2y - p1y) / (p2x - p1x),
- b = (c2y - p1y) / (c2x - p1x),
- c = (c1y - p1y) / (c1x - p1x);
- if ((Math.abs(b - a) + Math.abs(b - c)) / 2 < .1) {
- return pow(pow(p1x - p2x, 2) + pow(p1y - p2y, 2), .5);
- } else {
- var dot = R.findDotsAtSegment(p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y, .5);
- return segmentLength(p1x, p1y, dot.start.x, dot.start.y, dot.m.x, dot.m.y, dot.x, dot.y) +
- segmentLength(dot.x, dot.y, dot.n.x, dot.n.y, dot.end.x, dot.end.y, p2x, p2y);
+ var old = {x: 0, y: 0},
+ len = 0;
+ for (var i = 0; i < 1.01; i+=.01) {
+ var dot = findDotAtSegment(p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y, i);
+ i && (len += pow(pow(old.x - dot.x, 2) + pow(old.y - dot.y, 2), .5));
+ old = dot;
}
+ return len;
});
var getTotalLength = getLengthFactory(1),
getPointAtLength = getLengthFactory(),
@@ -3112,9 +3110,9 @@ Raphael = (function () {
to[attr] = params[attr];
switch (availableAnimAttrs[attr]) {
case "along":
- var len = getTotalLength(params[attr]),
- point = getPointAtLength(params[attr], len * !!params.back),
- bb = this.getBBox();
+ var len = getTotalLength(params[attr]);
+ var point = getPointAtLength(params[attr], len * !!params.back);
+ var bb = this.getBBox();
diff[attr] = len / ms;
diff.tx = bb.x;
diff.ty = bb.y;

0 comments on commit fa3418b

Please sign in to comment.
Something went wrong with that request. Please try again.