From: DmitryBaranovskiy Date: Thu, 6 May 2010 23:49:58 +0000 (+1000) Subject: 1.4.0 X-Git-Tag: v1.4.0~1 X-Git-Url: http://git.roojs.org/?p=raphael;a=commitdiff_plain;h=b9b2413b5dde29f5a6d0fd3b2b54a8f7be2779ac 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 --- diff --git a/raphael.js b/raphael.js index 4fd6725..d3d79bb 100644 --- a/raphael.js +++ b/raphael.js @@ -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,6 +2553,7 @@ 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; @@ -2551,21 +2561,24 @@ Raphael = (function () { 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 = {};