This repository has been archived by the owner on Mar 13, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Handle case where PointerGestures is loaded asynchronously
Part of Polymer/platform-dev#11
- Loading branch information
Showing
3 changed files
with
39 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,5 +8,6 @@ | |
"src/track.js", | ||
"src/flick.js", | ||
"src/pinch.js", | ||
"src/tap.js" | ||
"src/tap.js", | ||
"src/registerScopes.js" | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
* Copyright 2013 The Polymer Authors. All rights reserved. | ||
* Use of this source code is governed by a BSD-style | ||
* license that can be found in the LICENSE file. | ||
*/ | ||
|
||
/** | ||
* Because recognizers are loaded after dispatcher, we have to wait to register | ||
* scopes until after all the recognizers. | ||
*/ | ||
(function(scope) { | ||
var dispatcher = scope.dispatcher; | ||
function registerScopes() { | ||
dispatcher.immediateRegister = true; | ||
var rq = dispatcher.registerQueue; | ||
rq.forEach(scope.register); | ||
rq.length = 0; | ||
} | ||
if (document.readyState === 'complete') { | ||
registerScopes(); | ||
} else { | ||
// register scopes after a steadystate is reached | ||
// less MutationObserver churn | ||
document.addEventListener('readystatechange', function() { | ||
if (document.readyState === 'complete') { | ||
registerScopes(); | ||
} | ||
}); | ||
} | ||
})(window.PointerGestures); |