1

I have some issues with Hammer JS,

in the chrome developer tool I have some errors :

  • Uncaught ReferenceError: TOUCH_ACTION_COMPUTE is not defined hammer.js:37(anonymous function)

The file seems to be corrupted ? but I downloaded it from hammer js and never opened it...

  • Uncaught ReferenceError: ifUndefined is not defined hammer.js:9Hammer hammer.js:9(anonymous function) main.js:663j jQuery.js:2k.fireWith jQuery.js:2n.extend.ready jQuery.js:2I

Don't know what this refers to...

jQuery is loaded in first in my HTML page

My script wich calls hammer actions :

var hammer = new Hammer($('img'));

    hammer.on("tap", function(ev){
        alert(ev);
    });

Hope you'll be able to help me, thanks in advance.

5
  • is the code wrapped in $(document).ready(function() { ... }); or something equivalent?
    – Latheesan
    Commented Oct 7, 2014 at 10:22
  • Of course yes @Latheesan
    – Kirgan
    Commented Oct 7, 2014 at 10:25
  • I don't believe Hammer.js has built-in support for jQuery objects. Try new Hammer($('img')[0]) instead, to pass the native DOM element. Alternatively you may want to include the Hammer.js jQuery plugin and use $('img').hammer().bind("tap", function() { ... });.
    – Shai
    Commented Oct 7, 2014 at 10:52
  • I suspect that won't solve your core issue though. Download a fresh copy of hammer.js from the official web site / GitHub. (Also should be on rather than bind in my above example).
    – Shai
    Commented Oct 7, 2014 at 10:57
  • Seems still doesn't work... I have this $('img').hammer().on("tap", function() { console.log('hello'); });
    – Kirgan
    Commented Oct 10, 2014 at 8:26

1 Answer 1

3

You have probably reference the wrong js file in your webpage. If using the npm package make sure to reference <script src="/node_modules/hammerjs/hammer.js"></script> and NOT <script src="/node_modules/hammerjs/src/hammer.js"></script>

1
  • thanks, this helped me out... I was referencing the file inside the src folder.
    – Migs
    Commented Nov 15, 2017 at 22:53

Not the answer you're looking for? Browse other questions tagged or ask your own question.