Skip to content
This repository has been archived by the owner on Sep 5, 2024. It is now read-only.

Commit

Permalink
fix(gestures): attach event listeners once when multiple ng-apps are …
Browse files Browse the repository at this point in the history
…running

Closes #2173. Closes #2278.
  • Loading branch information
kennethcachia authored and ThomasBurleson committed Apr 13, 2015
1 parent 9affd12 commit 6d56676
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/core/services/gesture/gesture.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
*/
var pointer, lastPointer;

// Used to attach event listeners once when multiple ng-apps are running.
var isInitialized = false;

angular
.module('material.core.gestures', [ ])
.factory('$mdGesture', MdGesture)
Expand Down Expand Up @@ -390,7 +393,7 @@
return document.body.contains(node);
});

if ( $mdGesture.isHijackingClicks ) {
if (!isInitialized && $mdGesture.isHijackingClicks) {
/*
* If hijack clicks is true, we preventDefault any click that wasn't
* sent by ngMaterial. This is because on older Android & iOS, a false, or 'ghost',
Expand All @@ -408,6 +411,8 @@
ev.stopPropagation();
}
}, true);

isInitialized = true;
}

// Listen to all events to cover all platforms.
Expand Down

0 comments on commit 6d56676

Please sign in to comment.