ext-panning.js 913 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /*globals svgEditor, svgCanvas*/
  2. /*jslint eqeq: true*/
  3. /*
  4. * ext-panning.js
  5. *
  6. * Licensed under the MIT License
  7. *
  8. * Copyright(c) 2013 Luis Aguirre
  9. *
  10. */
  11. /*
  12. This is a very basic SVG-Edit extension to let tablet/mobile devices panning without problem
  13. */
  14. svgEditor.addExtension('ext-panning', function() {'use strict';
  15. return {
  16. name: 'Extension Panning',
  17. svgicons: svgEditor.curConfig.extPath + 'ext-panning.xml',
  18. buttons: [{
  19. id: 'ext-panning',
  20. type: 'mode',
  21. title: 'Panning',
  22. events: {
  23. click: function() {
  24. svgCanvas.setMode('ext-panning');
  25. }
  26. }
  27. }],
  28. mouseDown: function() {
  29. if (svgCanvas.getMode() == 'ext-panning') {
  30. svgEditor.setPanning(true);
  31. return {started: true};
  32. }
  33. },
  34. mouseUp: function() {
  35. if (svgCanvas.getMode() == 'ext-panning') {
  36. svgEditor.setPanning(false);
  37. return {
  38. keep: false,
  39. element: null
  40. };
  41. }
  42. }
  43. };
  44. });