Permalink
Browse files

1.4.0

• Touch events support
• rgba support
• new method drag
• document.onmousemove = f → Raphael.mousemove(f)
• resetScale method
• scaling text will change it position, but not size
• sets now have type “set”
• rect in VML doesn’t recreate itself on change of the R
• pathes are not rounded to the nearby pixels anymore
• Various small bug fixes and improvements
• added preventDefault and stopPropagation to event object
  • Loading branch information...
1 parent 8fedd8a commit b9b2413b5dde29f5a6d0fd3b2b54a8f7be2779ac @DmitryBaranovskiy committed May 6, 2010
Showing with 22 additions and 9 deletions.
  1. +22 −9 raphael.js
View
@@ -2476,7 +2476,13 @@ Raphael = (function () {
}
// Events
- var addEvent = (function () {
+ var preventDefault = function () {
+ this.returnValue = false;
+ },
+ stopPropagation = function () {
+ this.cancelBubble = true;
+ },
+ addEvent = (function () {
if (doc.addEventListener) {
return function (obj, type, fn, element) {
var f = function (e) {
@@ -2501,7 +2507,10 @@ Raphael = (function () {
} else if (doc.attachEvent) {
return function (obj, type, fn, element) {
var f = function (e) {
- return fn.call(element, e || win.event);
+ e = e || win.event;
+ e.preventDefault = e.preventDefault || preventDefault;
+ e.stopPropagation = e.stopPropagation || stopPropagation;
+ return fn.call(element, e);
};
obj.attachEvent("on" + type, f);
var detacher = function () {
@@ -2544,28 +2553,32 @@ Raphael = (function () {
Element[proto].drag = function (onmove, onstart, onend) {
this._drag = {};
var el = this.mousedown(function (e) {
+ e.preventDefault();
this._drag.x = e.clientX;
this._drag.y = e.clientY;
this._drag.id = e.identifier;
onstart && onstart.call(this, e.clientX, e.clientY);
Raphael.mousemove(move).mouseup(up);
}),
move = function (e) {
+ var x = e.clientX,
+ y = e.clientY;
if (supportsTouch) {
- for (var i = 0, ii = e.touches.length; i < ii; i++) {
- var touch = e.touches[i];
+ var i = e.touches.length,
+ touch;
+ while (i--) {
+ touch = e.touches[i];
if (touch.identifier == el._drag.id) {
- onmove && onmove.call(el, touch.clientX - el._drag.x, touch.clientY - el._drag.y, touch.clientX, touch.clientY);
+ x = touch.clientX;
+ y = touch.clientY;
e.preventDefault();
break;
}
}
} else {
- onmove && onmove.call(el, e.clientX - el._drag.x, e.clientY - el._drag.y, e.clientX, e.clientY);
- e.preventDefault && e.preventDefault();
- e.returnValue = false;
- return false;
+ e.preventDefault();
}
+ onmove && onmove.call(el, x - el._drag.x, y - el._drag.y, x, y);
},
up = function () {
el._drag = {};

0 comments on commit b9b2413

Please sign in to comment.