Browse Source

Try to load hammer.js from window before loading via require()

v3_develop
jos 10 years ago
parent
commit
7ee15a1854
1 changed files with 2 additions and 1 deletions
  1. +2
    -1
      lib/module/hammer.js

+ 2
- 1
lib/module/hammer.js View File

@ -1,7 +1,8 @@
// Only load hammer.js when in a browser environment // Only load hammer.js when in a browser environment
// (loading hammer.js in a node.js environment gives errors) // (loading hammer.js in a node.js environment gives errors)
if (typeof window !== 'undefined') { if (typeof window !== 'undefined') {
module.exports = require('hammerjs');
module.exports = window['Hammer'] || require('hammerjs');
// TODO: throw an error when hammerjs is not available?
} }
else { else {
module.exports = function () { module.exports = function () {

Loading…
Cancel
Save