vis.js is a dynamic, browser-based visualization library
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 lines
835 B

  1. var Hammer = require('./module/hammer');
  2. /**
  3. * Fake a hammer.js gesture. Event can be a ScrollEvent or MouseMoveEvent
  4. * @param {Element} element
  5. * @param {Event} event
  6. */
  7. exports.fakeGesture = function(element, event) {
  8. var eventType = null;
  9. // for hammer.js 1.0.5
  10. // var gesture = Hammer.event.collectEventData(this, eventType, event);
  11. // for hammer.js 1.0.6+
  12. var touches = Hammer.event.getTouchList(event, eventType);
  13. var gesture = Hammer.event.collectEventData(this, eventType, touches, event);
  14. // on IE in standards mode, no touches are recognized by hammer.js,
  15. // resulting in NaN values for center.pageX and center.pageY
  16. if (isNaN(gesture.center.pageX)) {
  17. gesture.center.pageX = event.pageX;
  18. }
  19. if (isNaN(gesture.center.pageY)) {
  20. gesture.center.pageY = event.pageY;
  21. }
  22. return gesture;
  23. };