@antv/g-plugin-dragndrop 1.5.0-alpha.0 → 1.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"DragndropPlugin.d.ts","sourceRoot":"","sources":["../src/DragndropPlugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAIV,eAAe,EACf,gBAAgB,EACjB,MAAM,SAAS,CAAC;AACjB,OAAO,EAIL,iBAAiB,EAElB,MAAM,SAAS,CAAC;AAIjB,qBACa,eAAgB,YAAW,eAAe;IACrD,MAAM,CAAC,GAAG,SAAe;IAGzB,SAAS,CAAC,iBAAiB,EAAE,iBAAiB,CAAC;IAG/C,OAAO,CAAC,gBAAgB,CAAmB;IAG3C,OAAO,CAAC,sBAAsB,CAAyB;IAEvD,KAAK,CAAC,gBAAgB,EAAE,gBAAgB;CAuIzC"}
1
+ {"version":3,"file":"DragndropPlugin.d.ts","sourceRoot":"","sources":["../src/DragndropPlugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAIV,eAAe,EACf,gBAAgB,EACjB,MAAM,SAAS,CAAC;AACjB,OAAO,EAIL,iBAAiB,EAElB,MAAM,SAAS,CAAC;AAIjB,qBACa,eAAgB,YAAW,eAAe;IACrD,MAAM,CAAC,GAAG,SAAe;IAGzB,SAAS,CAAC,iBAAiB,EAAE,iBAAiB,CAAC;IAG/C,OAAO,CAAC,gBAAgB,CAAmB;IAG3C,OAAO,CAAC,sBAAsB,CAAyB;IAEvD,KAAK,CAAC,gBAAgB,EAAE,gBAAgB;CA4IzC"}
package/dist/index.d.ts CHANGED
@@ -1,10 +1,10 @@
1
- import type { RendererPlugin, Syringe } from '@antv/g';
1
+ import { AbstractRendererPlugin } from '@antv/g';
2
2
  import { DragndropPluginOptions } from './tokens';
3
- export declare class Plugin implements RendererPlugin {
3
+ export declare class Plugin extends AbstractRendererPlugin {
4
4
  private options;
5
5
  name: string;
6
6
  constructor(options?: Partial<DragndropPluginOptions>);
7
- init(container: Syringe.Container): void;
8
- destroy(container: Syringe.Container): void;
7
+ init(): void;
8
+ destroy(): void;
9
9
  }
10
10
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAGvD,OAAO,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAC;AAMlD,qBAAa,MAAO,YAAW,cAAc;IAG/B,OAAO,CAAC,OAAO;IAF3B,IAAI,SAAe;gBAEC,OAAO,GAAE,OAAO,CAAC,sBAAsB,CAAM;IAEjE,IAAI,CAAC,SAAS,EAAE,OAAO,CAAC,SAAS,GAAG,IAAI;IAaxC,OAAO,CAAC,SAAS,EAAE,OAAO,CAAC,SAAS,GAAG,IAAI;CAI5C"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAU,MAAM,SAAS,CAAC;AAEzD,OAAO,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAC;AAMlD,qBAAa,MAAO,SAAQ,sBAAsB;IAGpC,OAAO,CAAC,OAAO;IAF3B,IAAI,SAAe;gBAEC,OAAO,GAAE,OAAO,CAAC,sBAAsB,CAAM;IAIjE,IAAI,IAAI,IAAI;IAaZ,OAAO,IAAI,IAAI;CAIhB"}
package/dist/index.esm.js CHANGED
@@ -1,4 +1,4 @@
1
- import { Syringe, inject, SceneGraphService, RenderingContext, singleton, RenderingPluginContribution, Module } from '@antv/g';
1
+ import { Syringe, inject, SceneGraphService, RenderingContext, singleton, RenderingPluginContribution, Module, AbstractRendererPlugin } from '@antv/g';
2
2
  import { __decorate, __metadata } from 'tslib';
3
3
  import { distanceSquareRoot } from '@antv/util';
4
4
 
@@ -400,6 +400,21 @@ function _extends() {
400
400
  return _extends.apply(this, arguments);
401
401
  }
402
402
 
403
+ function _inheritsLoose(subClass, superClass) {
404
+ subClass.prototype = Object.create(superClass.prototype);
405
+ subClass.prototype.constructor = subClass;
406
+
407
+ _setPrototypeOf(subClass, superClass);
408
+ }
409
+
410
+ function _setPrototypeOf(o, p) {
411
+ _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
412
+ o.__proto__ = p;
413
+ return o;
414
+ };
415
+ return _setPrototypeOf(o, p);
416
+ }
417
+
403
418
  var DragndropPluginOptions = Syringe.defineToken('DragndropPluginOptions');
404
419
 
405
420
  var _class;
@@ -546,7 +561,12 @@ var DragndropPlugin = DragndropPlugin_1 = (_class = /*#__PURE__*/function () {
546
561
  } // @see https://developer.mozilla.org/zh-CN/docs/Web/API/Document/dragend_event
547
562
 
548
563
 
549
- event.type = 'dragend';
564
+ event.type = 'dragend'; // prevent click event being triggerd
565
+ // @see https://github.com/antvis/G/issues/1091
566
+
567
+ event.detail = {
568
+ preventClick: true
569
+ };
550
570
  target.dispatchEvent(event);
551
571
  dragstartTriggered = false;
552
572
  }
@@ -598,21 +618,27 @@ DragndropPlugin = DragndropPlugin_1 = __decorate([singleton({
598
618
  var containerModule = Module(function (register) {
599
619
  register(DragndropPlugin);
600
620
  });
601
- var Plugin = /*#__PURE__*/function () {
621
+ var Plugin = /*#__PURE__*/function (_AbstractRendererPlug) {
622
+ _inheritsLoose(Plugin, _AbstractRendererPlug);
623
+
602
624
  function Plugin(options) {
625
+ var _this;
626
+
603
627
  if (options === void 0) {
604
628
  options = {};
605
629
  }
606
630
 
607
- this.options = void 0;
608
- this.name = 'dragndrop';
609
- this.options = options;
631
+ _this = _AbstractRendererPlug.call(this) || this;
632
+ _this.options = void 0;
633
+ _this.name = 'dragndrop';
634
+ _this.options = options;
635
+ return _this;
610
636
  }
611
637
 
612
638
  var _proto = Plugin.prototype;
613
639
 
614
- _proto.init = function init(container) {
615
- container.register(DragndropPluginOptions, {
640
+ _proto.init = function init() {
641
+ this.container.register(DragndropPluginOptions, {
616
642
  useValue: _extends({
617
643
  overlap: 'pointer',
618
644
  isDocumentDraggable: false,
@@ -621,15 +647,15 @@ var Plugin = /*#__PURE__*/function () {
621
647
  dragstartTimeThreshold: 0
622
648
  }, this.options)
623
649
  });
624
- container.load(containerModule, true);
650
+ this.container.load(containerModule, true);
625
651
  };
626
652
 
627
- _proto.destroy = function destroy(container) {
628
- container.remove(DragndropPluginOptions);
629
- container.unload(containerModule);
653
+ _proto.destroy = function destroy() {
654
+ this.container.remove(DragndropPluginOptions);
655
+ this.container.unload(containerModule);
630
656
  };
631
657
 
632
658
  return Plugin;
633
- }();
659
+ }(AbstractRendererPlugin);
634
660
 
635
661
  export { Plugin };
package/dist/index.js CHANGED
@@ -404,6 +404,21 @@ function _extends() {
404
404
  return _extends.apply(this, arguments);
405
405
  }
406
406
 
407
+ function _inheritsLoose(subClass, superClass) {
408
+ subClass.prototype = Object.create(superClass.prototype);
409
+ subClass.prototype.constructor = subClass;
410
+
411
+ _setPrototypeOf(subClass, superClass);
412
+ }
413
+
414
+ function _setPrototypeOf(o, p) {
415
+ _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
416
+ o.__proto__ = p;
417
+ return o;
418
+ };
419
+ return _setPrototypeOf(o, p);
420
+ }
421
+
407
422
  var DragndropPluginOptions = g.Syringe.defineToken('DragndropPluginOptions');
408
423
 
409
424
  var _class;
@@ -550,7 +565,12 @@ var DragndropPlugin = DragndropPlugin_1 = (_class = /*#__PURE__*/function () {
550
565
  } // @see https://developer.mozilla.org/zh-CN/docs/Web/API/Document/dragend_event
551
566
 
552
567
 
553
- event.type = 'dragend';
568
+ event.type = 'dragend'; // prevent click event being triggerd
569
+ // @see https://github.com/antvis/G/issues/1091
570
+
571
+ event.detail = {
572
+ preventClick: true
573
+ };
554
574
  target.dispatchEvent(event);
555
575
  dragstartTriggered = false;
556
576
  }
@@ -602,21 +622,27 @@ DragndropPlugin = DragndropPlugin_1 = tslib.__decorate([g.singleton({
602
622
  var containerModule = g.Module(function (register) {
603
623
  register(DragndropPlugin);
604
624
  });
605
- var Plugin = /*#__PURE__*/function () {
625
+ var Plugin = /*#__PURE__*/function (_AbstractRendererPlug) {
626
+ _inheritsLoose(Plugin, _AbstractRendererPlug);
627
+
606
628
  function Plugin(options) {
629
+ var _this;
630
+
607
631
  if (options === void 0) {
608
632
  options = {};
609
633
  }
610
634
 
611
- this.options = void 0;
612
- this.name = 'dragndrop';
613
- this.options = options;
635
+ _this = _AbstractRendererPlug.call(this) || this;
636
+ _this.options = void 0;
637
+ _this.name = 'dragndrop';
638
+ _this.options = options;
639
+ return _this;
614
640
  }
615
641
 
616
642
  var _proto = Plugin.prototype;
617
643
 
618
- _proto.init = function init(container) {
619
- container.register(DragndropPluginOptions, {
644
+ _proto.init = function init() {
645
+ this.container.register(DragndropPluginOptions, {
620
646
  useValue: _extends({
621
647
  overlap: 'pointer',
622
648
  isDocumentDraggable: false,
@@ -625,15 +651,15 @@ var Plugin = /*#__PURE__*/function () {
625
651
  dragstartTimeThreshold: 0
626
652
  }, this.options)
627
653
  });
628
- container.load(containerModule, true);
654
+ this.container.load(containerModule, true);
629
655
  };
630
656
 
631
- _proto.destroy = function destroy(container) {
632
- container.remove(DragndropPluginOptions);
633
- container.unload(containerModule);
657
+ _proto.destroy = function destroy() {
658
+ this.container.remove(DragndropPluginOptions);
659
+ this.container.unload(containerModule);
634
660
  };
635
661
 
636
662
  return Plugin;
637
- }();
663
+ }(g.AbstractRendererPlugin);
638
664
 
639
665
  exports.Plugin = Plugin;
package/dist/index.umd.js CHANGED
@@ -402,6 +402,21 @@
402
402
  return _extends.apply(this, arguments);
403
403
  }
404
404
 
405
+ function _inheritsLoose(subClass, superClass) {
406
+ subClass.prototype = Object.create(superClass.prototype);
407
+ subClass.prototype.constructor = subClass;
408
+
409
+ _setPrototypeOf(subClass, superClass);
410
+ }
411
+
412
+ function _setPrototypeOf(o, p) {
413
+ _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
414
+ o.__proto__ = p;
415
+ return o;
416
+ };
417
+ return _setPrototypeOf(o, p);
418
+ }
419
+
405
420
  /******************************************************************************
406
421
  Copyright (c) Microsoft Corporation.
407
422
 
@@ -578,7 +593,12 @@
578
593
  } // @see https://developer.mozilla.org/zh-CN/docs/Web/API/Document/dragend_event
579
594
 
580
595
 
581
- event.type = 'dragend';
596
+ event.type = 'dragend'; // prevent click event being triggerd
597
+ // @see https://github.com/antvis/G/issues/1091
598
+
599
+ event.detail = {
600
+ preventClick: true
601
+ };
582
602
  target.dispatchEvent(event);
583
603
  dragstartTriggered = false;
584
604
  }
@@ -630,21 +650,27 @@
630
650
  var containerModule = g.Module(function (register) {
631
651
  register(DragndropPlugin);
632
652
  });
633
- var Plugin = /*#__PURE__*/function () {
653
+ var Plugin = /*#__PURE__*/function (_AbstractRendererPlug) {
654
+ _inheritsLoose(Plugin, _AbstractRendererPlug);
655
+
634
656
  function Plugin(options) {
657
+ var _this;
658
+
635
659
  if (options === void 0) {
636
660
  options = {};
637
661
  }
638
662
 
639
- this.options = void 0;
640
- this.name = 'dragndrop';
641
- this.options = options;
663
+ _this = _AbstractRendererPlug.call(this) || this;
664
+ _this.options = void 0;
665
+ _this.name = 'dragndrop';
666
+ _this.options = options;
667
+ return _this;
642
668
  }
643
669
 
644
670
  var _proto = Plugin.prototype;
645
671
 
646
- _proto.init = function init(container) {
647
- container.register(DragndropPluginOptions, {
672
+ _proto.init = function init() {
673
+ this.container.register(DragndropPluginOptions, {
648
674
  useValue: _extends({
649
675
  overlap: 'pointer',
650
676
  isDocumentDraggable: false,
@@ -653,16 +679,16 @@
653
679
  dragstartTimeThreshold: 0
654
680
  }, this.options)
655
681
  });
656
- container.load(containerModule, true);
682
+ this.container.load(containerModule, true);
657
683
  };
658
684
 
659
- _proto.destroy = function destroy(container) {
660
- container.remove(DragndropPluginOptions);
661
- container.unload(containerModule);
685
+ _proto.destroy = function destroy() {
686
+ this.container.remove(DragndropPluginOptions);
687
+ this.container.unload(containerModule);
662
688
  };
663
689
 
664
690
  return Plugin;
665
- }();
691
+ }(g.AbstractRendererPlugin);
666
692
 
667
693
  exports.Plugin = Plugin;
668
694
 
@@ -1,3 +1,3 @@
1
1
  !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@antv/g")):"function"==typeof define&&define.amd?define(["exports","@antv/g"],e):e(((t="undefined"!=typeof globalThis?globalThis:t||self).G=t.G||{},t.G.Dragndrop={}),t.window.G)}(this,(function(t,e){"use strict";function r(){
2
2
  /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
3
- r=function(){return t};var t={},e=Object.prototype,n=e.hasOwnProperty,o="function"==typeof Symbol?Symbol:{},i=o.iterator||"@@iterator",a=o.asyncIterator||"@@asyncIterator",c=o.toStringTag||"@@toStringTag";function u(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{u({},"")}catch(t){u=function(t,e,r){return t[e]=r}}function s(t,e,r,n){var o=Object.create((e&&e.prototype instanceof p?e:p).prototype),i=new O(n||[]);return o._invoke=function(t,e,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return P()}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var c=x(a,r);if(c){if(c===f)continue;return c}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var u=l(t,e,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===f)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}(t,r,i),o}function l(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=s;var f={};function p(){}function h(){}function d(){}var v={};u(v,i,(function(){return this}));var y=Object.getPrototypeOf,g=y&&y(y(j([])));g&&g!==e&&n.call(g,i)&&(v=g);var m=d.prototype=p.prototype=Object.create(v);function w(t){["next","throw","return"].forEach((function(e){u(t,e,(function(t){return this._invoke(e,t)}))}))}function b(t,e){function r(o,i,a,c){var u=l(t[o],t,i);if("throw"!==u.type){var s=u.arg,f=s.value;return f&&"object"==typeof f&&n.call(f,"__await")?e.resolve(f.__await).then((function(t){r("next",t,a,c)}),(function(t){r("throw",t,a,c)})):e.resolve(f).then((function(t){s.value=t,a(s)}),(function(t){return r("throw",t,a,c)}))}c(u.arg)}var o;this._invoke=function(t,n){function i(){return new e((function(e,o){r(t,n,e,o)}))}return o=o?o.then(i,i):i()}}function x(t,e){var r=t.iterator[e.method];if(void 0===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,x(t,e),"throw"===e.method))return f;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return f}var n=l(r,t.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,f;var o=n.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,f):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,f)}function E(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function L(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function O(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(E,this),this.reset(!0)}function j(t){if(t){var e=t[i];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var r=-1,o=function e(){for(;++r<t.length;)if(n.call(t,r))return e.value=t[r],e.done=!1,e;return e.value=void 0,e.done=!0,e};return o.next=o}}return{next:P}}function P(){return{value:void 0,done:!0}}return h.prototype=d,u(m,"constructor",d),u(d,"constructor",h),h.displayName=u(d,c,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===h||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,d):(t.__proto__=d,u(t,c,"GeneratorFunction")),t.prototype=Object.create(m),t},t.awrap=function(t){return{__await:t}},w(b.prototype),u(b.prototype,a,(function(){return this})),t.AsyncIterator=b,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var a=new b(s(e,r,n,o),i);return t.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},w(m),u(m,c,"Generator"),u(m,i,(function(){return this})),u(m,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=j,O.prototype={constructor:O,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(L),!t)for(var e in this)"t"===e.charAt(0)&&n.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function r(r,n){return a.type="throw",a.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return r("end");if(this.prev>=i.tryLoc){var c=n.call(i,"catchLoc"),u=n.call(i,"finallyLoc");if(c&&u){if(i.catchLoc>this.prev)return r(i.catchLoc,!0);if(i.finallyLoc>this.prev)return r(i.finallyLoc)}else if(c){if(i.catchLoc>this.prev)return r(i.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(i.finallyLoc>this.prev)return r(i.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r];if(this.prev>=o.tryLoc&&n.call(o,"finallyLoc")&&o.finallyLoc>this.prev){var i=o;break}}i&&("break"===t||"continue"===t)&&e>=i.tryLoc&&i.finallyLoc>=e&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,f):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),f},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),L(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;L(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function n(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function o(t){return function(){var e=this,r=arguments;return new Promise((function(o,i){var a=t.apply(e,r);function c(t){n(a,o,i,c,u,"next",t)}function u(t){n(a,o,i,c,u,"throw",t)}c(void 0)}))}}function i(){return i=Object.assign?Object.assign.bind():function(t){for(var e=1;arguments.length>e;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t},i.apply(this,arguments)}function a(t,e,r,n){var o,i=arguments.length,a=3>i?e:null===n?n=Object.getOwnPropertyDescriptor(e,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,e,r,n);else for(var c=t.length-1;c>=0;c--)(o=t[c])&&(a=(3>i?o(a):i>3?o(e,r,a):o(e,r))||a);return i>3&&a&&Object.defineProperty(e,r,a),a}function c(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)}var u,s,l=e.Syringe.defineToken("DragndropPluginOptions"),f=(u=function(){function t(){this.sceneGraphService=void 0,this.renderingContext=void 0,this.dragndropPluginOptions=void 0}return t.prototype.apply=function(t){var e=this.renderingContext.root.ownerDocument,n=e.defaultView,i=this.dragndropPluginOptions,a=i.overlap,c=i.isDocumentDraggable,u=i.isDocumentDroppable,l=i.dragstartDistanceThreshold,f=i.dragstartTimeThreshold,p=function(t){var i=t.target,s=i===e;if(s&&c||i.getAttribute&&i.getAttribute("draggable")){var p=function(){var t=o(r().mark((function t(n){var o,c,p,m,w,b;return r().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(h){t.next=8;break}if(o=n.timeStamp-d,r=[n.clientX,n.clientY],x=v,c=Math.sqrt((r[0]-x[0])*(r[0]-x[0])+(r[1]-x[1])*(r[1]-x[1])),o>f&&c>l){t.next=5;break}return t.abrupt("return");case 5:n.type="dragstart",i.dispatchEvent(n),h=!0;case 8:if(n.type="drag",n.dx=n.clientX-g[0],n.dy=n.clientY-g[1],i.dispatchEvent(n),g=[n.clientX,n.clientY],s){t.next=23;break}return p=i.style.pointerEvents,i.style.pointerEvents="none",m="pointer"===a?[n.canvasX,n.canvasY]:i.getBounds().center,t.next=19,e.elementFromPoint(m[0],m[1]);case 19:w=t.sent,i.style.pointerEvents=p,b=(null==w?void 0:w.closest("[droppable=true]"))||(u?e:null),y!==b&&(y&&(n.type="dragleave",n.target=y,y.dispatchEvent(n)),b&&(n.type="dragenter",n.target=b,b.dispatchEvent(n)),(y=b)&&(n.type="dragover",n.target=y,y.dispatchEvent(n)));case 23:case"end":return t.stop()}var r,x}),t)})));return function(e){return t.apply(this,arguments)}}(),h=!1,d=t.timeStamp,v=[t.clientX,t.clientY],y=null,g=[t.clientX,t.clientY];n.addEventListener("pointermove",p);var m=function(){h&&(y&&(t.type="drop",t.target=y,y.dispatchEvent(t)),t.type="dragend",i.dispatchEvent(t),h=!1),n.removeEventListener("pointermove",p)};i.addEventListener("pointerup",m,{once:!0}),i.addEventListener("pointerupoutside",m,{once:!0})}};t.hooks.init.tapPromise(s.tag,o(r().mark((function t(){return r().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:n.addEventListener("pointerdown",p);case 1:case"end":return t.stop()}}),t)})))),t.hooks.destroy.tap(s.tag,(function(){n.removeEventListener("pointerdown",p)}))},t}(),u.tag="Dragndrop",s=u);a([e.inject(e.SceneGraphService),c("design:type",Object)],f.prototype,"sceneGraphService",void 0),a([e.inject(e.RenderingContext),c("design:type",Object)],f.prototype,"renderingContext",void 0),a([e.inject(l),c("design:type",Object)],f.prototype,"dragndropPluginOptions",void 0),f=s=a([e.singleton({contrib:e.RenderingPluginContribution})],f);var p=e.Module((function(t){t(f)}));t.Plugin=function(){function t(t){void 0===t&&(t={}),this.options=void 0,this.name="dragndrop",this.options=t}var e=t.prototype;return e.init=function(t){t.register(l,{useValue:i({overlap:"pointer",isDocumentDraggable:!1,isDocumentDroppable:!1,dragstartDistanceThreshold:0,dragstartTimeThreshold:0},this.options)}),t.load(p,!0)},e.destroy=function(t){t.remove(l),t.unload(p)},t}(),Object.defineProperty(t,"__esModule",{value:!0})}));
3
+ r=function(){return t};var t={},e=Object.prototype,n=e.hasOwnProperty,o="function"==typeof Symbol?Symbol:{},i=o.iterator||"@@iterator",a=o.asyncIterator||"@@asyncIterator",c=o.toStringTag||"@@toStringTag";function u(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{u({},"")}catch(t){u=function(t,e,r){return t[e]=r}}function s(t,e,r,n){var o=Object.create((e&&e.prototype instanceof f?e:f).prototype),i=new O(n||[]);return o._invoke=function(t,e,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return P()}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var c=x(a,r);if(c){if(c===p)continue;return c}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var u=l(t,e,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===p)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}(t,r,i),o}function l(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=s;var p={};function f(){}function h(){}function d(){}var v={};u(v,i,(function(){return this}));var y=Object.getPrototypeOf,g=y&&y(y(j([])));g&&g!==e&&n.call(g,i)&&(v=g);var m=d.prototype=f.prototype=Object.create(v);function w(t){["next","throw","return"].forEach((function(e){u(t,e,(function(t){return this._invoke(e,t)}))}))}function b(t,e){function r(o,i,a,c){var u=l(t[o],t,i);if("throw"!==u.type){var s=u.arg,p=s.value;return p&&"object"==typeof p&&n.call(p,"__await")?e.resolve(p.__await).then((function(t){r("next",t,a,c)}),(function(t){r("throw",t,a,c)})):e.resolve(p).then((function(t){s.value=t,a(s)}),(function(t){return r("throw",t,a,c)}))}c(u.arg)}var o;this._invoke=function(t,n){function i(){return new e((function(e,o){r(t,n,e,o)}))}return o=o?o.then(i,i):i()}}function x(t,e){var r=t.iterator[e.method];if(void 0===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,x(t,e),"throw"===e.method))return p;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return p}var n=l(r,t.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,p;var o=n.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,p):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,p)}function E(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function L(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function O(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(E,this),this.reset(!0)}function j(t){if(t){var e=t[i];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var r=-1,o=function e(){for(;++r<t.length;)if(n.call(t,r))return e.value=t[r],e.done=!1,e;return e.value=void 0,e.done=!0,e};return o.next=o}}return{next:P}}function P(){return{value:void 0,done:!0}}return h.prototype=d,u(m,"constructor",d),u(d,"constructor",h),h.displayName=u(d,c,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===h||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,d):(t.__proto__=d,u(t,c,"GeneratorFunction")),t.prototype=Object.create(m),t},t.awrap=function(t){return{__await:t}},w(b.prototype),u(b.prototype,a,(function(){return this})),t.AsyncIterator=b,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var a=new b(s(e,r,n,o),i);return t.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},w(m),u(m,c,"Generator"),u(m,i,(function(){return this})),u(m,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=j,O.prototype={constructor:O,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(L),!t)for(var e in this)"t"===e.charAt(0)&&n.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function r(r,n){return a.type="throw",a.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return r("end");if(this.prev>=i.tryLoc){var c=n.call(i,"catchLoc"),u=n.call(i,"finallyLoc");if(c&&u){if(i.catchLoc>this.prev)return r(i.catchLoc,!0);if(i.finallyLoc>this.prev)return r(i.finallyLoc)}else if(c){if(i.catchLoc>this.prev)return r(i.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(i.finallyLoc>this.prev)return r(i.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r];if(this.prev>=o.tryLoc&&n.call(o,"finallyLoc")&&o.finallyLoc>this.prev){var i=o;break}}i&&("break"===t||"continue"===t)&&e>=i.tryLoc&&i.finallyLoc>=e&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,p):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),p},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),L(r),p}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;L(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),p}},t}function n(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function o(t){return function(){var e=this,r=arguments;return new Promise((function(o,i){var a=t.apply(e,r);function c(t){n(a,o,i,c,u,"next",t)}function u(t){n(a,o,i,c,u,"throw",t)}c(void 0)}))}}function i(){return i=Object.assign?Object.assign.bind():function(t){for(var e=1;arguments.length>e;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t},i.apply(this,arguments)}function a(t,e){return a=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},a(t,e)}function c(t,e,r,n){var o,i=arguments.length,a=3>i?e:null===n?n=Object.getOwnPropertyDescriptor(e,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,e,r,n);else for(var c=t.length-1;c>=0;c--)(o=t[c])&&(a=(3>i?o(a):i>3?o(e,r,a):o(e,r))||a);return i>3&&a&&Object.defineProperty(e,r,a),a}function u(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)}var s,l,p=e.Syringe.defineToken("DragndropPluginOptions"),f=(s=function(){function t(){this.sceneGraphService=void 0,this.renderingContext=void 0,this.dragndropPluginOptions=void 0}return t.prototype.apply=function(t){var e=this.renderingContext.root.ownerDocument,n=e.defaultView,i=this.dragndropPluginOptions,a=i.overlap,c=i.isDocumentDraggable,u=i.isDocumentDroppable,s=i.dragstartDistanceThreshold,p=i.dragstartTimeThreshold,f=function(t){var i=t.target,l=i===e;if(l&&c||i.getAttribute&&i.getAttribute("draggable")){var f=function(){var t=o(r().mark((function t(n){var o,c,f,m,w,b;return r().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(h){t.next=8;break}if(o=n.timeStamp-d,r=[n.clientX,n.clientY],x=v,c=Math.sqrt((r[0]-x[0])*(r[0]-x[0])+(r[1]-x[1])*(r[1]-x[1])),o>p&&c>s){t.next=5;break}return t.abrupt("return");case 5:n.type="dragstart",i.dispatchEvent(n),h=!0;case 8:if(n.type="drag",n.dx=n.clientX-g[0],n.dy=n.clientY-g[1],i.dispatchEvent(n),g=[n.clientX,n.clientY],l){t.next=23;break}return f=i.style.pointerEvents,i.style.pointerEvents="none",m="pointer"===a?[n.canvasX,n.canvasY]:i.getBounds().center,t.next=19,e.elementFromPoint(m[0],m[1]);case 19:w=t.sent,i.style.pointerEvents=f,b=(null==w?void 0:w.closest("[droppable=true]"))||(u?e:null),y!==b&&(y&&(n.type="dragleave",n.target=y,y.dispatchEvent(n)),b&&(n.type="dragenter",n.target=b,b.dispatchEvent(n)),(y=b)&&(n.type="dragover",n.target=y,y.dispatchEvent(n)));case 23:case"end":return t.stop()}var r,x}),t)})));return function(e){return t.apply(this,arguments)}}(),h=!1,d=t.timeStamp,v=[t.clientX,t.clientY],y=null,g=[t.clientX,t.clientY];n.addEventListener("pointermove",f);var m=function(){h&&(y&&(t.type="drop",t.target=y,y.dispatchEvent(t)),t.type="dragend",t.detail={preventClick:!0},i.dispatchEvent(t),h=!1),n.removeEventListener("pointermove",f)};i.addEventListener("pointerup",m,{once:!0}),i.addEventListener("pointerupoutside",m,{once:!0})}};t.hooks.init.tapPromise(l.tag,o(r().mark((function t(){return r().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:n.addEventListener("pointerdown",f);case 1:case"end":return t.stop()}}),t)})))),t.hooks.destroy.tap(l.tag,(function(){n.removeEventListener("pointerdown",f)}))},t}(),s.tag="Dragndrop",l=s);c([e.inject(e.SceneGraphService),u("design:type",Object)],f.prototype,"sceneGraphService",void 0),c([e.inject(e.RenderingContext),u("design:type",Object)],f.prototype,"renderingContext",void 0),c([e.inject(p),u("design:type",Object)],f.prototype,"dragndropPluginOptions",void 0),f=l=c([e.singleton({contrib:e.RenderingPluginContribution})],f);var h=e.Module((function(t){t(f)}));t.Plugin=function(t){var e,r;function n(e){var r;return void 0===e&&(e={}),(r=t.call(this)||this).options=void 0,r.name="dragndrop",r.options=e,r}r=t,(e=n).prototype=Object.create(r.prototype),e.prototype.constructor=e,a(e,r);var o=n.prototype;return o.init=function(){this.container.register(p,{useValue:i({overlap:"pointer",isDocumentDraggable:!1,isDocumentDroppable:!1,dragstartDistanceThreshold:0,dragstartTimeThreshold:0},this.options)}),this.container.load(h,!0)},o.destroy=function(){this.container.remove(p),this.container.unload(h)},n}(e.AbstractRendererPlugin),Object.defineProperty(t,"__esModule",{value:!0})}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antv/g-plugin-dragndrop",
3
- "version": "1.5.0-alpha.0",
3
+ "version": "1.5.2",
4
4
  "description": "A G plugin for Drag n Drop implemented with PointerEvents",
5
5
  "keywords": [
6
6
  "antv",
@@ -27,7 +27,7 @@
27
27
  "README.md"
28
28
  ],
29
29
  "dependencies": {
30
- "@antv/util": "^3.2.0",
30
+ "@antv/util": "^3.2.2",
31
31
  "tslib": "^2.3.1"
32
32
  },
33
33
  "devDependencies": {
@@ -39,5 +39,5 @@
39
39
  "publishConfig": {
40
40
  "access": "public"
41
41
  },
42
- "gitHead": "94fbafea28d1f2910720172b7e45a859c8e3a454"
42
+ "gitHead": "cc3e4646317ec49518138205c8d53daa6f3f1229"
43
43
  }