var Hammer = require('./module/hammer'); /** * Fake a hammer.js gesture. Event can be a ScrollEvent or MouseMoveEvent * @param {Element} element * @param {Event} event */ exports.fakeGesture = function(element, event) { var eventType = null; // for hammer.js 1.0.5 // var gesture = Hammer.event.collectEventData(this, eventType, event); // for hammer.js 1.0.6+ var touches = Hammer.event.getTouchList(event, eventType); var gesture = Hammer.event.collectEventData(this, eventType, touches, event); // on IE in standards mode, no touches are recognized by hammer.js, // resulting in NaN values for center.pageX and center.pageY if (isNaN(gesture.center.pageX)) { gesture.center.pageX = event.pageX; } if (isNaN(gesture.center.pageY)) { gesture.center.pageY = event.pageY; } return gesture; };