[Pkg-javascript-commits] [dojo] 18/21: Support unprefixed pointer events in dojo/touch
David Prévot
taffit at moszumanska.debian.org
Thu Aug 21 17:39:54 UTC 2014
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to annotated tag 1.9.2
in repository dojo.
commit c4029a7d68cc4d9dcc0eaab8c292ffbbd702482e
Author: Colin Snover <github.com at zetafleet.com>
Date: Fri Nov 29 21:15:08 2013 +0000
Support unprefixed pointer events in dojo/touch
Refs #17600
(cherry picked from commit de651e625d9d2dc9220e7a02647689a4299777d5)
---
tests/test_touch.html | 5 ++++-
touch.js | 31 ++++++++++++++++++++-----------
2 files changed, 24 insertions(+), 12 deletions(-)
diff --git a/tests/test_touch.html b/tests/test_touch.html
index 57b7224..f5083f4 100644
--- a/tests/test_touch.html
+++ b/tests/test_touch.html
@@ -300,7 +300,10 @@
}
// Setup tests relevant for this platform
- if(navigator.msPointerEnabled){
+ if(navigator.pointerEnabled){
+ register('Pointer events', 'pointerdown', 'pointermove', 'pointerup',
+ has('touch') ? 'pointercancel' : 'mouseout');
+ }else if(navigator.msPointerEnabled){
register('MSPointer events', 'MSPointerDown', 'MSPointerMove', 'MSPointerUp',
has('touch') ? 'MSPointerCancel' : 'mouseout');
}else{
diff --git a/touch.js b/touch.js
index a056772..5d55219 100644
--- a/touch.js
+++ b/touch.js
@@ -8,7 +8,16 @@ function(dojo, aspect, dom, domClass, lang, on, has, mouse, domReady, win){
var ios4 = has("ios") < 5;
- var msPointer = navigator.msPointerEnabled;
+ var msPointer = navigator.pointerEnabled || navigator.msPointerEnabled,
+ pointer = (function () {
+ var pointer = {};
+ for (var type in { down: 1, move: 1, up: 1, cancel: 1, over: 1, out: 1 }) {
+ pointer[type] = !navigator.pointerEnabled ?
+ "MSPointer" + type.charAt(0).toUpperCase() + type.slice(1) :
+ "pointer" + type;
+ }
+ return pointer;
+ })();
// Click generation variables
var clicksInited, clickTracker, clickTarget, clickX, clickY, clickDx, clickDy, clickTime;
@@ -143,8 +152,8 @@ function(dojo, aspect, dom, domClass, lang, on, has, mouse, domReady, win){
if(msPointer){
// MSPointer (IE10+) already has support for over and out, so we just need to init click support
domReady(function(){
- win.doc.addEventListener("MSPointerDown", function(evt){
- doClicks(evt, "MSPointerMove", "MSPointerUp");
+ win.doc.addEventListener(pointer.down, function(evt){
+ doClicks(evt, pointer.move, pointer.up);
}, true);
});
}else{
@@ -246,14 +255,14 @@ function(dojo, aspect, dom, domClass, lang, on, has, mouse, domReady, win){
//device neutral events - touch.press|move|release|cancel/over/out
var touch = {
- press: dualEvent("mousedown", "touchstart", "MSPointerDown"),
- move: dualEvent("mousemove", "dojotouchmove", "MSPointerMove"),
- release: dualEvent("mouseup", "dojotouchend", "MSPointerUp"),
- cancel: dualEvent(mouse.leave, "touchcancel", hasTouch?"MSPointerCancel":null),
- over: dualEvent("mouseover", "dojotouchover", "MSPointerOver"),
- out: dualEvent("mouseout", "dojotouchout", "MSPointerOut"),
- enter: mouse._eventHandler(dualEvent("mouseover","dojotouchover", "MSPointerOver")),
- leave: mouse._eventHandler(dualEvent("mouseout", "dojotouchout", "MSPointerOut"))
+ press: dualEvent("mousedown", "touchstart", pointer.down),
+ move: dualEvent("mousemove", "dojotouchmove", pointer.move),
+ release: dualEvent("mouseup", "dojotouchend", pointer.up),
+ cancel: dualEvent(mouse.leave, "touchcancel", hasTouch ? pointer.cancel : null),
+ over: dualEvent("mouseover", "dojotouchover", pointer.over),
+ out: dualEvent("mouseout", "dojotouchout", pointer.out),
+ enter: mouse._eventHandler(dualEvent("mouseover","dojotouchover", pointer.over)),
+ leave: mouse._eventHandler(dualEvent("mouseout", "dojotouchout", pointer.out))
};
/*=====
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/dojo.git
More information about the Pkg-javascript-commits
mailing list