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.

36 lines
755 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. function hammerMock() {
  7. const noop = () => {};
  8. return {
  9. on: noop,
  10. off: noop,
  11. destroy: noop,
  12. emit: noop,
  13. get: function(m) { //eslint-disable-line no-unused-vars
  14. return {
  15. set: noop
  16. };
  17. }
  18. };
  19. }
  20. if (typeof window !== 'undefined') {
  21. var propagating = require('propagating-hammerjs');
  22. var Hammer = window['Hammer'] || require('hammerjs');
  23. module.exports = propagating(Hammer, {
  24. preventDefault: 'mouse'
  25. });
  26. }
  27. else {
  28. module.exports = function () {
  29. // hammer.js is only available in a browser, not in node.js. Replacing it with a mock object.
  30. return hammerMock();
  31. }
  32. }