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.

48 lines
1.3 KiB

  1. var Hammer = require('./module/hammer');
  2. /**
  3. * Register a touch event, taking place before a gesture
  4. * @param {Hammer} hammer A hammer instance
  5. * @param {function} callback Callback, called as callback(event)
  6. */
  7. exports.onTouch = function (hammer, callback) {
  8. callback.inputHandler = function (event) {
  9. if (event.isFirst) {
  10. callback(event);
  11. }
  12. };
  13. hammer.on('hammer.input', callback.inputHandler);
  14. };
  15. /**
  16. * Register a release event, taking place after a gesture
  17. * @param {Hammer} hammer A hammer instance
  18. * @param {function} callback Callback, called as callback(event)
  19. */
  20. exports.onRelease = function (hammer, callback) {
  21. callback.inputHandler = function (event) {
  22. if (event.isFinal) {
  23. callback(event);
  24. }
  25. };
  26. return hammer.on('hammer.input', callback.inputHandler);
  27. };
  28. /**
  29. * Unregister a touch event, taking place before a gesture
  30. * @param {Hammer} hammer A hammer instance
  31. * @param {function} callback Callback, called as callback(event)
  32. */
  33. exports.offTouch = function (hammer, callback) {
  34. hammer.off('hammer.input', callback.inputHandler);
  35. };
  36. /**
  37. * Unregister a release event, taking place before a gesture
  38. * @param {Hammer} hammer A hammer instance
  39. * @param {function} callback Callback, called as callback(event)
  40. */
  41. exports.offRelease = exports.offTouch;