HammerJS undefined event properties

I am developing this small website: Website ; and I use HammerJS as a touch support library.

It seems to be responding to events, and it recognizes the event.type property, but when I try to get event.direction or other related properties with the drag event, nothing is output to the console (I am logging the results in the console).

This is how I listen to the drag event "

 Application.ApplicationController.prototype.Drag = function(selector, delay, callback) { return $(selector).on('drag', _.debounce(function(event){ event.preventDefault(); return (typeof callback === 'function' && callback !== undefined) ? callback.apply( event, [ event ] ) : 'Argument : Invalid [ Function Required ]'; }, delay)); }; 

I call it something like:

 this.Drag(selector, delay, function(event) { console.log(event.type, event.direction); }); 

Can someone tell me what I am doing wrong, or if something is missing?

EDIT: I just replaced the jQuery library: jquery.specialevents.hammer.js ; with old jquery.hammer.js ; and it seems that now he is reacting to all events, and I get all the properties that I should. However, I would like to know why I did not try to work with him?

EDIT: I found the root cause of my problem, my code depends on some libraries that I load asynchronously with the Yepnope script loader, so somewhere along the path instead of loading all the libraries (including the jquery plugin for hammer.js), some of them are lost: ) I fixed this problem and now events have properties that they should use.

+7
source share
2 answers

However, I would like to know why I did not try to work with him?

Understanding the difference between jquery.specialevent.hammer.js and jquery.hammer.js should help understand the problem. Damien, creator of jquery.specialevent.hammer.js , explains why .

However, Eight Media decided to create their own jQuery namespace to trigger events.

 $("#element").hammer({ /* options */ }).on("tap", function(ev) { console.log(ev); }); 

So in the end they do not use the default jQuery eventing system. This means that my existing source code jQuery Mobile Events needs to be changed. That's why I decided to implement using Hammer.JS using the jQuery special API.

 $("#element").on("tap", { /* options */ }, function(ev) { console.log(ev); }); 

I put jquery.specialevent.hammer.js on my Github where you can also find a demo. Perhaps eight media accept my pull request, and it will be part of Hammer.JS.

+9
source

event.gesture.direction should provide you with what you are looking for.

+5
source

All Articles