Skip to content

Commit

Permalink
* Global variables leakage fix
Browse files Browse the repository at this point in the history
  *  fix for elements with links
  * Gradient clean up
  * Added  attribute
  * Fixed hsb methods
  * Fixed image flickering
  * Improved  method on
  * Fixed drag'n'drop
  * New method [Paper.add](http://raphaeljs.com/reference.html#Paper.add)
  * Fix for
  • Loading branch information
DmitryBaranovskiy committed Nov 18, 2011
1 parent 3c49587 commit 10c3e3b
Show file tree
Hide file tree
Showing 7 changed files with 528 additions and 363 deletions.
49 changes: 49 additions & 0 deletions history.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
2.0.1 * 2011-11-18
------------------

* Global variables leakage fix
* `toFront` fix for elements with links
* Gradient clean up
* Added `letter-spacing` attribute
* Fixed hsb methods
* Fixed image flickering
* Improved `toTransformString` method on `matrix`
* Fixed drag'n'drop
* New method [Paper.add](http://raphaeljs.com/reference.html#Paper.add)
* Fix for `clip-path`

2.0.0 * 2011-10-03
------------------

* Completely changed transformation handling:
* `translate()`, `rotate()` and `scale()` are deprecated
* `translation`, `rotation` and `scale` attributes are removed (!)
* new method `transform()` and new attribute `transform` were introduced
* chaining of transformations now allowed
* matrix transformation introduced
* see [docs](http://raphaeljs.com/reference.html#Element.transform)
* Animation API was updated (see [docs](http://raphaeljs.com/reference.html#Raphael.animation))
* delay, repeat, [setTime](http://raphaeljs.com/reference.html#Element.status), [status](http://raphaeljs.com/reference.html#Element.setTime)
* New methods:
* [Paper.setViewBox](http://raphaeljs.com/reference.html#Paper.setViewBox)
* [Paper.setStart](http://raphaeljs.com/reference.html#Paper.setStart)
* [Paper.setFinish](http://raphaeljs.com/reference.html#Paper.setFinish)
* [Paper.forEach](http://raphaeljs.com/reference.html#Paper.forEach)
* [Paper.getById](http://raphaeljs.com/reference.html#Paper.getById)
* [Paper.getElementByPoint](http://raphaeljs.com/reference.html#Paper.getElementByPoint)
* [Element.data](http://raphaeljs.com/reference.html#Element.data)
* [Element.glow](http://raphaeljs.com/reference.html#Element.glow)
* [Element.onDragOver](http://raphaeljs.com/reference.html#Element.onDragOver)
* [Element.removeData](http://raphaeljs.com/reference.html#Element.removeData)
* [Raphael.fullfill](http://raphaeljs.com/reference.html#Raphael.fullfill)
* [Raphael.matrix](http://raphaeljs.com/reference.html#Raphael.matrix)
* [Raphael.parseTransformString](http://raphaeljs.com/reference.html#Raphael.parseTransformString)
* [Set.clear](http://raphaeljs.com/reference.html#Set.clear)
* [Set.exclude](http://raphaeljs.com/reference.html#Set.exclude)
* [Set.forEach](http://raphaeljs.com/reference.html#Set.forEach)
* [Set.splice](http://raphaeljs.com/reference.html#Set.splice)
* VML completely rewritten
* `getBBox` was fixed to take transformations into account
* [eve](http://raphaeljs.com/reference.html#eve) was added to the project
* Whole new [documentation](http://raphaeljs.com/reference.html)
* Various bug fixes
4 changes: 2 additions & 2 deletions raphael-min.js

Large diffs are not rendered by default.

104 changes: 72 additions & 32 deletions raphael.core.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// ┌─────────────────────────────────────────────────────────────────────┐ \\
// │ "Raphaël 2.0" - JavaScript Vector Library │ \\
// │ "Raphaël 2.0.1" - JavaScript Vector Library │ \\
// ├─────────────────────────────────────────────────────────────────────┤ \\
// │ Copyright (c) 2008-2011 Dmitry Baranovskiy (http://raphaeljs.com) │ \\
// │ Copyright (c) 2008-2011 Sencha Labs (http://sencha.com) │ \\
Expand All @@ -26,7 +26,7 @@
- height (number)
- callback (function) #optional callback function which is going to be executed in the context of newly created paper
* or
- all (array) (first 3 or 4 elements in the array are equal to [containerID, width, height] or [x, y, width, height]. The rest are element descriptions in format {type: type, <attributes>})
- all (array) (first 3 or 4 elements in the array are equal to [containerID, width, height] or [x, y, width, height]. The rest are element descriptions in format {type: type, <attributes>}). See @Paper.add.
- callback (function) #optional callback function which is going to be executed in the context of newly created paper
* or
- onReadyCallback (function) function that is going to be called on DOM ready event. You can also subscribe to this event via Eve’s “DOMLoad” event. In this case method returns `undefined`.
Expand Down Expand Up @@ -60,17 +60,7 @@
if (R.is(first, "function")) {
return loaded ? first() : eve.on("DOMload", first);
} else if (R.is(first, array)) {
var a = first,
cnv = R._engine.create[apply](R, a.splice(0, 3 + R.is(a[0], nu))),
res = cnv.set(),
i = 0,
ii = a.length,
j;
for (; i < ii; i++) {
j = a[i] || {};
elements[has](j.type) && res.push(cnv[j.type]().attr(j));
}
return res;
return R._engine.create[apply](R, first.splice(0, 3 + R.is(first[0], nu))).add(first);
} else {
var args = Array.prototype.slice.call(arguments, 0);
if (R.is(args[args.length - 1], "function")) {
Expand All @@ -83,7 +73,7 @@
}
}
}
R.version = "2.0.0";
R.version = "2.0.1";
R.eve = eve;
var loaded,
separator = /[, ]+/,
Expand Down Expand Up @@ -191,6 +181,7 @@
gradient: 0,
height: 0,
href: "http://raphaeljs.com/",
"letter-spacing": 0,
opacity: 1,
path: "M0,0",
r: 0,
Expand Down Expand Up @@ -293,7 +284,7 @@
if (!matrix) {
return path;
}
var x, y, i, j, pathi;
var x, y, i, j, ii, jj, pathi;
path = path2curve(path);
for (i = 0, ii = path.length; i < ii; i++) {
pathi = path[i];
Expand Down Expand Up @@ -501,8 +492,8 @@
eve("setWindow", R, g.win, newwin);
g.win = newwin;
g.doc = g.win.document;
if (initWin) {
initWin(g.win);
if (R._engine.initWin) {
R._engine.initWin(g.win);
}
};
var toHex = function (color) {
Expand Down Expand Up @@ -632,7 +623,7 @@
clr.v = rgb.b;
} else {
clr = {hex: "none"};
crl.r = clr.g = clr.b = clr.h = clr.s = clr.v = clr.l = -1;
clr.r = clr.g = clr.b = clr.h = clr.s = clr.v = clr.l = -1;
}
}
clr.toString = rgbtoString;
Expand Down Expand Up @@ -815,7 +806,7 @@

var preload = R._preload = function (src, f) {
var img = g.doc.createElement("img");
img.style.cssText = "position:absolute;left:-9999em;top-9999em";
img.style.cssText = "position:absolute;left:-9999em;top:-9999em";
img.onload = function () {
f.call(this);
this.onload = null;
Expand Down Expand Up @@ -1174,6 +1165,11 @@
alpha: alpha
};
};
R._removedFactory = function (methodname) {
return function () {
throw new Error("Rapha\xebl: you are calling to method \u201c" + methodname + "\u201d of removed object");
};
};
var pathDimensions = cacher(function (path) {
if (!path) {
return {x: 0, y: 0, width: 0, height: 0};
Expand Down Expand Up @@ -1719,11 +1715,6 @@
el2.prev = el;
el.next = el2;
},
removed = function (methodname) {
return function () {
throw new Error("Rapha\xebl: you are calling to method \u201c" + methodname + "\u201d of removed object");
};
},
extractTransform = R._extractTransform = function (el, tstr) {
if (tstr == null) {
return el._.transform;
Expand Down Expand Up @@ -2175,7 +2166,12 @@
matrixproto.toTransformString = function (shorter) {
var s = shorter || this[split]();
if (s.isSimple) {
return "t" + [s.dx, s.dy] + "s" + [s.scalex, s.scaley, 0, 0] + "r" + [s.rotate, 0, 0];
s.scalex = +s.scalex.toFixed(4);
s.scaley = +s.scaley.toFixed(4);
s.rotate = +s.rotate.toFixed(4);
return (s.dx && s.dy ? "t" + [s.dx, s.dy] : E) +
(s.scalex != 1 || s.scaley != 1 ? "s" + [s.scalex, s.scaley, 0, 0] : E) +
(s.rotate ? "r" + [s.rotate, 0, 0] : E);
} else {
return "m" + [this.get(0), this.get(1), this.get(2), this.get(3), this.get(4), this.get(5)];
}
Expand Down Expand Up @@ -2647,6 +2643,7 @@
elproto.unhover = function (f_in, f_out) {
return this.unmouseover(f_in).unmouseout(f_out);
};
var draggable = [];
/*\
* Element.drag
[ method ]
Expand Down Expand Up @@ -2693,6 +2690,7 @@
eve("drag.start." + this.id, start_scope || move_scope || this, e.clientX + scrollX, e.clientY + scrollY, e);
}
this._drag = {};
draggable.push({el: this, start: start});
this.mousedown(start);
return this;
};
Expand All @@ -2714,13 +2712,13 @@
* Removes all drag event handlers from given element.
\*/
elproto.undrag = function () {
var i = drag.length;
while (i--) if (drag[i].el == this) {
R.unmousedown(drag[i].start);
drag.splice(i++, 1);
var i = draggable.length;
while (i--) if (draggable[i].el == this) {
this.unmousedown(draggable[i].start);
draggable.splice(i, 1);
eve.unbind("drag.*." + this.id);
}
!drag.length && R.unmousemove(dragMove).unmouseup(dragUp);
!draggable.length && R.unmousemove(dragMove).unmouseup(dragUp);
};
/*\
* Paper.circle
Expand Down Expand Up @@ -3615,7 +3613,7 @@
= (object) original element
\*/
elproto.animateWith = function (element, anim, params, ms, easing, callback) {
var a = params ? R.animation(params, ms, easing, callback) : anim;
var a = params ? R.animation(params, ms, easing, callback) : anim,
status = element.status(anim);
return this.animate(a).status(a, status * anim.ms / a.ms);
};
Expand Down Expand Up @@ -3776,7 +3774,7 @@
return;
}
if (!isInAnim) {
for (attr in params) if (params[has](attr)) {
for (var attr in params) if (params[has](attr)) {
if (availableAnimAttrs[has](attr) || element.paper.customAttributes[has](attr)) {
from[attr] = element.attr(attr);
(from[attr] == null) && (from[attr] = availableAttrs[attr]);
Expand Down Expand Up @@ -4507,6 +4505,48 @@
return out;
};

/*\
* Paper.add
[ method ]
**
* Imports elements in JSON array in format `{type: type, <attributes>}`
**
> Parameters
**
- json (array)
= (object) resulting set of imported elements
> Usage
| paper.import([
| {
| type: "circle",
| cx: 10,
| cy: 10,
| r: 5
| },
| {
| type: "rect",
| x: 10,
| y: 10,
| width: 10,
| height: 10,
| fill: "#fc0"
| }
| ]);
\*/
paperproto.add = function (json) {
if (R.is(json, "array")) {
var res = this.set(),
i = 0,
ii = json.length,
j;
for (; i < ii; i++) {
j = json[i] || {};
elements[has](j.type) && res.push(this[j.type]().attr(j));
}
}
return res;
};

/*\
* Raphael.format
[ method ]
Expand Down
Loading

0 comments on commit 10c3e3b

Please sign in to comment.