graph-event.js 2.2 KB

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