Commit c007d401 by DmitryBaranovskiy

1.4.2

• fix animation callback for sets
• fix format method
• added touch event handlers circle.touchmove(function…)
parent 425ba722
/*! /*!
* Raphael 1.4.1 - JavaScript Vector Library * Raphael 1.4.2 - JavaScript Vector Library
* *
* Copyright (c) 2010 Dmitry Baranovskiy (http://raphaeljs.com) * Copyright (c) 2010 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.
...@@ -19,7 +19,7 @@ Raphael = (function () { ...@@ -19,7 +19,7 @@ Raphael = (function () {
} }
return create[apply](R, arguments); return create[apply](R, arguments);
} }
R.version = "1.4.1"; R.version = "1.4.2";
var separator = /[, ]+/, var separator = /[, ]+/,
elements = /^(circle|rect|path|ellipse|text|image)$/, elements = /^(circle|rect|path|ellipse|text|image)$/,
proto = "prototype", proto = "prototype",
...@@ -38,7 +38,7 @@ Raphael = (function () { ...@@ -38,7 +38,7 @@ Raphael = (function () {
E = "", E = "",
S = " ", S = " ",
split = "split", split = "split",
events = "click dblclick mousedown mousemove mouseout mouseover mouseup"[split](S), events = "click dblclick mousedown mousemove mouseout mouseover mouseup touchstart touchmove touchend orientationchange touchcancel gesturestart gesturechange gestureend"[split](S),
touchMap = { touchMap = {
mousedown: "touchstart", mousedown: "touchstart",
mousemove: "touchmove", mousemove: "touchmove",
...@@ -2479,19 +2479,27 @@ Raphael = (function () { ...@@ -2479,19 +2479,27 @@ Raphael = (function () {
var preventDefault = function () { var preventDefault = function () {
this.returnValue = false; this.returnValue = false;
}, },
preventTouch = function () {
return this.originalEvent.preventDefault();
},
stopPropagation = function () { stopPropagation = function () {
this.cancelBubble = true; this.cancelBubble = true;
}, },
stopTouch = function () {
return this.originalEvent.stopPropagation();
},
addEvent = (function () { addEvent = (function () {
if (doc.addEventListener) { if (doc.addEventListener) {
return function (obj, type, fn, element) { return function (obj, type, fn, element) {
var f = function (e) { var f = function (e) {
if (supportsTouch) { if (supportsTouch && touchMap[has](type)) {
for (var i = 0, ii = e.targetTouches && e.targetTouches.length; i < ii; i++) { for (var i = 0, ii = e.targetTouches && e.targetTouches.length; i < ii; i++) {
if (e.targetTouches[i].target == obj) { if (e.targetTouches[i].target == obj) {
var olde = e; var olde = e;
e = e.targetTouches[i]; e = e.targetTouches[i];
e.originalEvent = olde; e.originalEvent = olde;
e.preventDefault = preventTouch;
e.stopPropagation = stopTouch;
break; break;
} }
} }
...@@ -2756,6 +2764,9 @@ Raphael = (function () { ...@@ -2756,6 +2764,9 @@ Raphael = (function () {
return this; return this;
}; };
Element[proto].clone = function () { Element[proto].clone = function () {
if (this.removed) {
return null;
}
var attr = this.attr(); var attr = this.attr();
delete attr.scale; delete attr.scale;
delete attr.translation; delete attr.translation;
...@@ -3001,7 +3012,7 @@ Raphael = (function () { ...@@ -3001,7 +3012,7 @@ Raphael = (function () {
to.rot && that.rotate(diff.r + point.alpha, point.x, point.y); to.rot && that.rotate(diff.r + point.alpha, point.x, point.y);
} }
(t.x || t.y) && that.translate(-t.x, -t.y); (t.x || t.y) && that.translate(-t.x, -t.y);
to.scale && (to.scale = to.scale + E); to.scale && (to.scale += E);
that.attr(to); that.attr(to);
delete animationElements[l]; delete animationElements[l];
animationElements[length]--; animationElements[length]--;
...@@ -3227,14 +3238,16 @@ Raphael = (function () { ...@@ -3227,14 +3238,16 @@ Raphael = (function () {
(R.is(easing, "function") || !easing) && (callback = easing || null); (R.is(easing, "function") || !easing) && (callback = easing || null);
var len = this.items[length], var len = this.items[length],
i = len, i = len,
item,
set = this, set = this,
collector; collector;
callback && (collector = function () { callback && (collector = function () {
!--len && callback.call(set); !--len && callback.call(set);
}); });
this.items[--i].animate(params, ms, easing || collector, collector); easing = R.is(easing, string) ? easing : collector;
item = this.items[--i].animate(params, ms, easing, collector);
while (i--) { while (i--) {
this.items[i].animateWith(this.items[len - 1], params, ms, easing || collector, collector); this.items[i].animateWith(item, params, ms, easing, collector);
} }
return this; return this;
}; };
...@@ -3366,8 +3379,8 @@ Raphael = (function () { ...@@ -3366,8 +3379,8 @@ Raphael = (function () {
}; };
var formatrg = /\{(\d+)\}/g; var formatrg = /\{(\d+)\}/g;
R.format = function (token, array) { R.format = function (token, params) {
var args = R.is(array, array) ? [0][concat](array) : arguments; var args = R.is(params, array) ? [0][concat](params) : arguments;
token && R.is(token, string) && args[length] - 1 && (token = token[rp](formatrg, function (str, i) { token && R.is(token, string) && args[length] - 1 && (token = token[rp](formatrg, function (str, i) {
return args[++i] == null ? E : args[i]; return args[++i] == null ? E : args[i];
})); }));
......
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