tap polyfill only when from touch event

This commit is contained in:
Adam Bradley
2013-09-26 13:00:09 -05:00
parent 0b7c6ada06
commit e39f224fb9
4 changed files with 14 additions and 28 deletions

View File

@ -15,11 +15,11 @@
} }
function tapPolyfill(e) { function tapPolyfill(e) {
// evaluate the actual source event, not the created event by gestures.js // if the source event wasn't from a touch event then don't use this polyfill
if(!e.gesture) return; if(!e.gesture || e.gesture.pointerType !== "touch") return;
var var
e = e.gesture.srcEvent, e = e.gesture.srcEvent, // evaluate the actual source event, not the created event by gestures.js
ele = e.target; ele = e.target;
if(!e) return; if(!e) return;
@ -53,6 +53,6 @@
} }
// global tap event listener polyfill for HTML elements that were "tapped" by the user // global tap event listener polyfill for HTML elements that were "tapped" by the user
//ionic.on("tap", tapPolyfill, window); ionic.on("tap", tapPolyfill, window);
})(this, document, ionic); })(this, document, ionic);

13
dist/ionic.js vendored
View File

@ -293,16 +293,9 @@ if ( document.readyState === "complete" ) {
ionic.Gestures.event.determineEventTypes(); ionic.Gestures.event.determineEventTypes();
// Register all gestures inside ionic.Gestures.gestures // Register all gestures inside ionic.Gestures.gestures
if(this === this.window) { for(var name in ionic.Gestures.gestures) {
// this is a window, only add these if(ionic.Gestures.gestures.hasOwnProperty(name)) {
ionic.Gestures.detection.register(ionic.Gestures.gestures.Tap); ionic.Gestures.detection.register(ionic.Gestures.gestures[name]);
} else {
// everything else but the window
for(var name in ionic.Gestures.gestures) {
if(ionic.Gestures.gestures.hasOwnProperty(name)) {
ionic.Gestures.detection.register(ionic.Gestures.gestures[name]);
}
} }
} }

View File

@ -15,11 +15,11 @@
} }
function tapPolyfill(e) { function tapPolyfill(e) {
// evaluate the actual source event, not the created event by gestures.js // if the source event wasn't from a touch event then don't use this polyfill
if(!e.gesture) return; if(!e.gesture || e.gesture.pointerType !== "touch") return;
var var
e = e.gesture.srcEvent, e = e.gesture.srcEvent, // evaluate the actual source event, not the created event by gestures.js
ele = e.target; ele = e.target;
if(!e) return; if(!e) return;
@ -53,6 +53,6 @@
} }
// global tap event listener polyfill for HTML elements that were "tapped" by the user // global tap event listener polyfill for HTML elements that were "tapped" by the user
//ionic.on("tap", tapPolyfill, window); ionic.on("tap", tapPolyfill, window);
})(this, document, ionic); })(this, document, ionic);

View File

@ -90,16 +90,9 @@
ionic.Gestures.event.determineEventTypes(); ionic.Gestures.event.determineEventTypes();
// Register all gestures inside ionic.Gestures.gestures // Register all gestures inside ionic.Gestures.gestures
if(this === this.window) { for(var name in ionic.Gestures.gestures) {
// this is a window, only add these if(ionic.Gestures.gestures.hasOwnProperty(name)) {
ionic.Gestures.detection.register(ionic.Gestures.gestures.Tap); ionic.Gestures.detection.register(ionic.Gestures.gestures[name]);
} else {
// everything else but the window
for(var name in ionic.Gestures.gestures) {
if(ionic.Gestures.gestures.hasOwnProperty(name)) {
ionic.Gestures.detection.register(ionic.Gestures.gestures[name]);
}
} }
} }