graph-event.js 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. var GraphEvent = /** @class */ (function () {
  4. function GraphEvent(type, event) {
  5. /**
  6. * 是否允许冒泡
  7. * @type {boolean}
  8. */
  9. this.bubbles = true;
  10. /**
  11. * 触发对象
  12. * @type {object}
  13. */
  14. this.target = null;
  15. /**
  16. * 监听对象
  17. * @type {object}
  18. */
  19. this.currentTarget = null;
  20. /**
  21. * 委托对象
  22. * @type {object}
  23. */
  24. this.delegateTarget = null;
  25. /**
  26. * 委托事件监听对象的代理对象,即 ev.delegateObject = ev.currentTarget.get('delegateObject')
  27. * @type {object}
  28. */
  29. this.delegateObject = null;
  30. /**
  31. * 是否阻止了原生事件
  32. * @type {boolean}
  33. */
  34. this.defaultPrevented = false;
  35. /**
  36. * 是否阻止传播(向上冒泡)
  37. * @type {boolean}
  38. */
  39. this.propagationStopped = false;
  40. /**
  41. * 触发事件的图形
  42. * @type {IShape}
  43. */
  44. this.shape = null;
  45. /**
  46. * 开始触发事件的图形
  47. * @type {IShape}
  48. */
  49. this.fromShape = null;
  50. /**
  51. * 事件结束时的触发图形
  52. * @type {IShape}
  53. */
  54. this.toShape = null;
  55. // 触发事件的路径
  56. this.propagationPath = [];
  57. this.type = type;
  58. this.name = type;
  59. this.originalEvent = event;
  60. this.timeStamp = event.timeStamp;
  61. }
  62. /**
  63. * 阻止浏览器默认的行为
  64. */
  65. GraphEvent.prototype.preventDefault = function () {
  66. this.defaultPrevented = true;
  67. if (this.originalEvent.preventDefault) {
  68. this.originalEvent.preventDefault();
  69. }
  70. };
  71. /**
  72. * 阻止冒泡
  73. */
  74. GraphEvent.prototype.stopPropagation = function () {
  75. this.propagationStopped = true;
  76. };
  77. GraphEvent.prototype.toString = function () {
  78. var type = this.type;
  79. return "[Event (type=" + type + ")]";
  80. };
  81. GraphEvent.prototype.save = function () { };
  82. GraphEvent.prototype.restore = function () { };
  83. return GraphEvent;
  84. }());
  85. exports.default = GraphEvent;
  86. //# sourceMappingURL=graph-event.js.map