Skip to content

Commit

Permalink
feat(Hammer Global): exposes Hammer on window or self if either is de…
Browse files Browse the repository at this point in the history
…fined to avoid issues when AMD is present but not used.
  • Loading branch information
runspired committed Dec 21, 2015
1 parent 439c7a6 commit 356f795
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/expose.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ extend(Hammer, {
prefixed: prefixed
});

// this prevents errors when Hammer is loaded in the presence of an AMD
// style loader but by script tag, not by the loader.
var freeGlobal = (typeof window !== 'undefined' ? window : (typeof self !== 'undefined' ? self : {}));
freeGlobal.Hammer = Hammer;

if (typeof define === 'function' && define.amd) {
define(function() {
return Hammer;
Expand Down

0 comments on commit 356f795

Please sign in to comment.