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.

38 lines
831 B

  1. /**
  2. * Setup a mock hammer.js object, for unit testing.
  3. *
  4. * Inspiration: https://github.com/uber/deck.gl/pull/658
  5. *
  6. * @returns {{on: noop, off: noop, destroy: noop, emit: noop, get: get}}
  7. */
  8. function hammerMock() {
  9. const noop = () => {};
  10. return {
  11. on: noop,
  12. off: noop,
  13. destroy: noop,
  14. emit: noop,
  15. get: function(m) { //eslint-disable-line no-unused-vars
  16. return {
  17. set: noop
  18. };
  19. }
  20. };
  21. }
  22. if (typeof window !== 'undefined') {
  23. var propagating = require('propagating-hammerjs');
  24. var Hammer = window['Hammer'] || require('hammerjs');
  25. module.exports = propagating(Hammer, {
  26. preventDefault: 'mouse'
  27. });
  28. }
  29. else {
  30. module.exports = function () {
  31. // hammer.js is only available in a browser, not in node.js. Replacing it with a mock object.
  32. return hammerMock();
  33. }
  34. }