From b9b2413b5dde29f5a6d0fd3b2b54a8f7be2779ac Mon Sep 17 00:00:00 2001 From: DmitryBaranovskiy Date: Fri, 7 May 2010 09:49:58 +1000 Subject: [PATCH] =?utf8?q?1.4.0=20=E2=80=A2=20Touch=20events=20support=20?= =?utf8?q?=E2=80=A2=20rgba=20support=20=E2=80=A2=20new=20method=20drag=20?= =?utf8?q?=E2=80=A2=20document.onmousemove=20=3D=20f=20=E2=86=92=20Raphael?= =?utf8?q?.mousemove(f)=20=E2=80=A2=20resetScale=20method=20=E2=80=A2=20sc?= =?utf8?q?aling=20text=20will=20change=20it=20position,=20but=20not=20size?= =?utf8?q?=20=E2=80=A2=20sets=20now=20have=20type=20=E2=80=9Cset=E2=80=9D?= =?utf8?q?=20=E2=80=A2=20rect=20in=20VML=20doesn=E2=80=99t=20recreate=20it?= =?utf8?q?self=20on=20change=20of=20the=20R=20=E2=80=A2=20pathes=20are=20n?= =?utf8?q?ot=20rounded=20to=20the=20nearby=20pixels=20anymore=20=E2=80=A2?= =?utf8?q?=20Various=20small=20bug=20fixes=20and=20improvements=20?= =?utf8?q?=E2=80=A2=20added=20preventDefault=20and=20stopPropagation=20to?= =?utf8?q?=20event=20object?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- raphael.js | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) 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 = {}; -- 2.39.2