Merge branch 'Touchit-fix-touch-events' into v2.1.1
* Touchit-fix-touch-events: Updating files from latest merge Tweaks to previous merge getPath (and method that use) now working with simple elements like "Circle" Fix Touch events selection in dragMove method Fix Gruntfile to build in windows environment Fix Touch events on Firefox and Chrome Conflicts: raphael-min.js
This commit is contained in:
commit
426680e32d
|
|
@ -55,7 +55,7 @@ module.exports = function(grunt) {
|
||||||
svgorvmlRegex = /\.(svg|vml)\.js/,
|
svgorvmlRegex = /\.(svg|vml)\.js/,
|
||||||
closureRegex = /window\.Raphael.*\(R\)\s*\{/,
|
closureRegex = /window\.Raphael.*\(R\)\s*\{/,
|
||||||
closureEndRegex = /\}\(window\.Raphael\);\s*$/,
|
closureEndRegex = /\}\(window\.Raphael\);\s*$/,
|
||||||
exposeRegex = /(\n\s*\/\/\s*EXPOSE(?:\n|.)*\}\)\);)/;
|
exposeRegex = /(\r?\n\s*\/\/\s*EXPOSE(?:\r|\n|.)*\}\)\);)/;
|
||||||
|
|
||||||
// Concatenate src
|
// Concatenate src
|
||||||
src.forEach(function(path) {
|
src.forEach(function(path) {
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
|
|
@ -2704,19 +2704,31 @@
|
||||||
stopTouch = function () {
|
stopTouch = function () {
|
||||||
return this.originalEvent.stopPropagation();
|
return this.originalEvent.stopPropagation();
|
||||||
},
|
},
|
||||||
|
getEventPosition = function (e) {
|
||||||
|
var scrollY = g.doc.documentElement.scrollTop || g.doc.body.scrollTop,
|
||||||
|
scrollX = g.doc.documentElement.scrollLeft || g.doc.body.scrollLeft;
|
||||||
|
|
||||||
|
return {
|
||||||
|
x: e.clientX + scrollX,
|
||||||
|
y: e.clientY + scrollY
|
||||||
|
};
|
||||||
|
},
|
||||||
addEvent = (function () {
|
addEvent = (function () {
|
||||||
if (g.doc.addEventListener) {
|
if (g.doc.addEventListener) {
|
||||||
return function (obj, type, fn, element) {
|
return function (obj, type, fn, element) {
|
||||||
var realName = supportsTouch && touchMap[type] ? touchMap[type] : type,
|
var f = function (e) {
|
||||||
f = function (e) {
|
var pos = getEventPosition(e);
|
||||||
var scrollY = g.doc.documentElement.scrollTop || g.doc.body.scrollTop,
|
return fn.call(element, e, pos.x, pos.y);
|
||||||
scrollX = g.doc.documentElement.scrollLeft || g.doc.body.scrollLeft,
|
};
|
||||||
x = e.clientX + scrollX,
|
obj.addEventListener(type, f, false);
|
||||||
y = e.clientY + scrollY;
|
|
||||||
if (supportsTouch && touchMap[has](type)) {
|
if (supportsTouch && touchMap[type]) {
|
||||||
|
var _f = function (e) {
|
||||||
|
var pos = getEventPosition(e),
|
||||||
|
olde = e;
|
||||||
|
|
||||||
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;
|
|
||||||
e = e.targetTouches[i];
|
e = e.targetTouches[i];
|
||||||
e.originalEvent = olde;
|
e.originalEvent = olde;
|
||||||
e.preventDefault = preventTouch;
|
e.preventDefault = preventTouch;
|
||||||
|
|
@ -2724,12 +2736,18 @@
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return fn.call(element, e, x, y);
|
return fn.call(element, e, pos.x, pos.y);
|
||||||
};
|
};
|
||||||
obj.addEventListener(realName, f, false);
|
obj.addEventListener(touchMap[type], _f, false);
|
||||||
|
}
|
||||||
|
|
||||||
return function () {
|
return function () {
|
||||||
obj.removeEventListener(realName, f, false);
|
obj.removeEventListener(type, f, false);
|
||||||
|
|
||||||
|
if (supportsTouch && touchMap[type])
|
||||||
|
obj.removeEventListener(touchMap[type], f, false);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
@ -2764,7 +2782,7 @@
|
||||||
j = drag.length;
|
j = drag.length;
|
||||||
while (j--) {
|
while (j--) {
|
||||||
dragi = drag[j];
|
dragi = drag[j];
|
||||||
if (supportsTouch) {
|
if (supportsTouch && e.touches) {
|
||||||
var i = e.touches.length,
|
var i = e.touches.length,
|
||||||
touch;
|
touch;
|
||||||
while (i--) {
|
while (i--) {
|
||||||
|
|
@ -3881,11 +3899,16 @@
|
||||||
= (number) length.
|
= (number) length.
|
||||||
\*/
|
\*/
|
||||||
elproto.getTotalLength = function () {
|
elproto.getTotalLength = function () {
|
||||||
if (this.type != "path") {return;}
|
var path = this.getPath();
|
||||||
|
if (!path) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (this.node.getTotalLength) {
|
if (this.node.getTotalLength) {
|
||||||
return this.node.getTotalLength();
|
return this.node.getTotalLength();
|
||||||
}
|
}
|
||||||
return getTotalLength(this.attrs.path);
|
|
||||||
|
return getTotalLength(path);
|
||||||
};
|
};
|
||||||
/*\
|
/*\
|
||||||
* Element.getPointAtLength
|
* Element.getPointAtLength
|
||||||
|
|
@ -3905,8 +3928,34 @@
|
||||||
o }
|
o }
|
||||||
\*/
|
\*/
|
||||||
elproto.getPointAtLength = function (length) {
|
elproto.getPointAtLength = function (length) {
|
||||||
if (this.type != "path") {return;}
|
var path = this.getPath();
|
||||||
return getPointAtLength(this.attrs.path, length);
|
if (!path) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
return getPointAtLength(path, length);
|
||||||
|
};
|
||||||
|
/*\
|
||||||
|
* Element.getPath
|
||||||
|
[ method ]
|
||||||
|
**
|
||||||
|
* Returns path of the element. Only works for elements of “path” type and simple elements like circle.
|
||||||
|
= (object) path
|
||||||
|
**
|
||||||
|
\*/
|
||||||
|
elproto.getPath = function () {
|
||||||
|
var path,
|
||||||
|
getPath = R._getPath[this.type];
|
||||||
|
|
||||||
|
if (this.type == "text" || this.type == "set") {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (getPath) {
|
||||||
|
path = getPath(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
return path;
|
||||||
};
|
};
|
||||||
/*\
|
/*\
|
||||||
* Element.getSubpath
|
* Element.getSubpath
|
||||||
|
|
@ -3922,8 +3971,12 @@
|
||||||
= (string) pathstring for the segment
|
= (string) pathstring for the segment
|
||||||
\*/
|
\*/
|
||||||
elproto.getSubpath = function (from, to) {
|
elproto.getSubpath = function (from, to) {
|
||||||
if (this.type != "path") {return;}
|
var path = this.getPath();
|
||||||
return R.getSubpath(this.attrs.path, from, to);
|
if (!path) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
return R.getSubpath(path, from, to);
|
||||||
};
|
};
|
||||||
/*\
|
/*\
|
||||||
* Raphael.easing_formulas
|
* Raphael.easing_formulas
|
||||||
|
|
|
||||||
93
raphael.js
93
raphael.js
|
|
@ -3083,19 +3083,31 @@
|
||||||
stopTouch = function () {
|
stopTouch = function () {
|
||||||
return this.originalEvent.stopPropagation();
|
return this.originalEvent.stopPropagation();
|
||||||
},
|
},
|
||||||
|
getEventPosition = function (e) {
|
||||||
|
var scrollY = g.doc.documentElement.scrollTop || g.doc.body.scrollTop,
|
||||||
|
scrollX = g.doc.documentElement.scrollLeft || g.doc.body.scrollLeft;
|
||||||
|
|
||||||
|
return {
|
||||||
|
x: e.clientX + scrollX,
|
||||||
|
y: e.clientY + scrollY
|
||||||
|
};
|
||||||
|
},
|
||||||
addEvent = (function () {
|
addEvent = (function () {
|
||||||
if (g.doc.addEventListener) {
|
if (g.doc.addEventListener) {
|
||||||
return function (obj, type, fn, element) {
|
return function (obj, type, fn, element) {
|
||||||
var realName = supportsTouch && touchMap[type] ? touchMap[type] : type,
|
var f = function (e) {
|
||||||
f = function (e) {
|
var pos = getEventPosition(e);
|
||||||
var scrollY = g.doc.documentElement.scrollTop || g.doc.body.scrollTop,
|
return fn.call(element, e, pos.x, pos.y);
|
||||||
scrollX = g.doc.documentElement.scrollLeft || g.doc.body.scrollLeft,
|
};
|
||||||
x = e.clientX + scrollX,
|
obj.addEventListener(type, f, false);
|
||||||
y = e.clientY + scrollY;
|
|
||||||
if (supportsTouch && touchMap[has](type)) {
|
if (supportsTouch && touchMap[type]) {
|
||||||
|
var _f = function (e) {
|
||||||
|
var pos = getEventPosition(e),
|
||||||
|
olde = e;
|
||||||
|
|
||||||
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;
|
|
||||||
e = e.targetTouches[i];
|
e = e.targetTouches[i];
|
||||||
e.originalEvent = olde;
|
e.originalEvent = olde;
|
||||||
e.preventDefault = preventTouch;
|
e.preventDefault = preventTouch;
|
||||||
|
|
@ -3103,12 +3115,18 @@
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return fn.call(element, e, x, y);
|
return fn.call(element, e, pos.x, pos.y);
|
||||||
};
|
};
|
||||||
obj.addEventListener(realName, f, false);
|
obj.addEventListener(touchMap[type], _f, false);
|
||||||
|
}
|
||||||
|
|
||||||
return function () {
|
return function () {
|
||||||
obj.removeEventListener(realName, f, false);
|
obj.removeEventListener(type, f, false);
|
||||||
|
|
||||||
|
if (supportsTouch && touchMap[type])
|
||||||
|
obj.removeEventListener(touchMap[type], f, false);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
@ -3143,7 +3161,7 @@
|
||||||
j = drag.length;
|
j = drag.length;
|
||||||
while (j--) {
|
while (j--) {
|
||||||
dragi = drag[j];
|
dragi = drag[j];
|
||||||
if (supportsTouch) {
|
if (supportsTouch && e.touches) {
|
||||||
var i = e.touches.length,
|
var i = e.touches.length,
|
||||||
touch;
|
touch;
|
||||||
while (i--) {
|
while (i--) {
|
||||||
|
|
@ -4260,11 +4278,16 @@
|
||||||
= (number) length.
|
= (number) length.
|
||||||
\*/
|
\*/
|
||||||
elproto.getTotalLength = function () {
|
elproto.getTotalLength = function () {
|
||||||
if (this.type != "path") {return;}
|
var path = this.getPath();
|
||||||
|
if (!path) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (this.node.getTotalLength) {
|
if (this.node.getTotalLength) {
|
||||||
return this.node.getTotalLength();
|
return this.node.getTotalLength();
|
||||||
}
|
}
|
||||||
return getTotalLength(this.attrs.path);
|
|
||||||
|
return getTotalLength(path);
|
||||||
};
|
};
|
||||||
/*\
|
/*\
|
||||||
* Element.getPointAtLength
|
* Element.getPointAtLength
|
||||||
|
|
@ -4284,8 +4307,34 @@
|
||||||
o }
|
o }
|
||||||
\*/
|
\*/
|
||||||
elproto.getPointAtLength = function (length) {
|
elproto.getPointAtLength = function (length) {
|
||||||
if (this.type != "path") {return;}
|
var path = this.getPath();
|
||||||
return getPointAtLength(this.attrs.path, length);
|
if (!path) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
return getPointAtLength(path, length);
|
||||||
|
};
|
||||||
|
/*\
|
||||||
|
* Element.getPath
|
||||||
|
[ method ]
|
||||||
|
**
|
||||||
|
* Returns path of the element. Only works for elements of “path” type and simple elements like circle.
|
||||||
|
= (object) path
|
||||||
|
**
|
||||||
|
\*/
|
||||||
|
elproto.getPath = function () {
|
||||||
|
var path,
|
||||||
|
getPath = R._getPath[this.type];
|
||||||
|
|
||||||
|
if (this.type == "text" || this.type == "set") {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (getPath) {
|
||||||
|
path = getPath(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
return path;
|
||||||
};
|
};
|
||||||
/*\
|
/*\
|
||||||
* Element.getSubpath
|
* Element.getSubpath
|
||||||
|
|
@ -4301,8 +4350,12 @@
|
||||||
= (string) pathstring for the segment
|
= (string) pathstring for the segment
|
||||||
\*/
|
\*/
|
||||||
elproto.getSubpath = function (from, to) {
|
elproto.getSubpath = function (from, to) {
|
||||||
if (this.type != "path") {return;}
|
var path = this.getPath();
|
||||||
return R.getSubpath(this.attrs.path, from, to);
|
if (!path) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
return R.getSubpath(path, from, to);
|
||||||
};
|
};
|
||||||
/*\
|
/*\
|
||||||
* Raphael.easing_formulas
|
* Raphael.easing_formulas
|
||||||
|
|
|
||||||
|
|
@ -1,37 +1,37 @@
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<head>
|
<head>
|
||||||
<title>Raphael Dev testing html</title>
|
<title>Raphael Dev testing html</title>
|
||||||
|
|
||||||
<!-- HTML to try new developments in Raphael -->
|
<!-- HTML to try new developments in Raphael -->
|
||||||
|
|
||||||
<!-- Global use -->
|
<!-- Global use -->
|
||||||
|
|
||||||
<!-- Remember to run to pull the eve submodule -->
|
<!-- Remember to run to pull the eve submodule -->
|
||||||
<!-- To work with concatenated version -->
|
<!-- To work with concatenated version -->
|
||||||
<!--<script type="text/javascript" src="raphael.js"></script>-->
|
<!--<script type="text/javascript" src="raphael.js"></script>-->
|
||||||
|
|
||||||
<!-- To work with minified version -->
|
<!-- To work with minified version -->
|
||||||
<!--<script type="text/javascript" src="raphael-min.js"></script>-->
|
<!--<script type="text/javascript" src="raphael-min.js"></script>-->
|
||||||
|
|
||||||
<!-- To work with dev versions -->
|
<!-- To work with dev versions -->
|
||||||
<script type="text/javascript" src=" ./eve/eve.js"></script>
|
<script type="text/javascript" src=" ./eve/eve.js"></script>
|
||||||
<script type="text/javascript" src="raphael.core.js"></script>
|
<script type="text/javascript" src="raphael.core.js"></script>
|
||||||
<script type="text/javascript" src="raphael.svg.js"></script>
|
<script type="text/javascript" src="raphael.svg.js"></script>
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
// Initialize container when document is loaded
|
// Initialize container when document is loaded
|
||||||
window.onload = function(){
|
window.onload = function () {
|
||||||
paper = Raphael(0, 0, 640, 720, "container");
|
paper = Raphael(0, 0, 640, 720, "container");
|
||||||
};
|
};
|
||||||
//Work here, in a separate script file or via command line
|
//Work here, in a separate script file or via command line
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<!-- AMD use -->
|
<!-- AMD use -->
|
||||||
<!--<script data-main="test" src="require.js"></script>-->
|
<!--<script data-main="test" src="require.js"></script>-->
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<!-- Container for svg/vml root element -->
|
<!-- Container for svg/vml root element -->
|
||||||
<div id="container"></div>
|
<div id="container"></div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
Loading…
Reference in New Issue