UNPKG

@antv/g6

Version:

graph visualization frame work

2 lines 5.25 kB
!function(t,n){"object"==typeof exports&&"object"==typeof module?module.exports=n():"function"==typeof define&&define.amd?define([],n):"object"==typeof exports?exports.Menu=n():t.Menu=n()}(window,function(){return function(t){var n={};function e(o){if(n[o])return n[o].exports;var r=n[o]={i:o,l:!1,exports:{}};return t[o].call(r.exports,r,r.exports,e),r.l=!0,r.exports}return e.m=t,e.c=n,e.d=function(t,n,o){e.o(t,n)||Object.defineProperty(t,n,{enumerable:!0,get:o})},e.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},e.t=function(t,n){if(1&n&&(t=e(t)),8&n)return t;if(4&n&&"object"==typeof t&&t&&t.__esModule)return t;var o=Object.create(null);if(e.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:t}),2&n&&"string"!=typeof t)for(var r in t)e.d(o,r,function(n){return t[n]}.bind(null,r));return o},e.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(n,"a",n),n},e.o=function(t,n){return Object.prototype.hasOwnProperty.call(t,n)},e.p="",e(e.s=40)}({12:function(t,n){var e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t};t.exports=function(t){var n=void 0===t?"undefined":e(t);return null!==t&&"object"===n||"function"===n}},14:function(t,n){var e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t};t.exports=function(t){return"object"===(void 0===t?"undefined":e(t))&&null!==t}},15:function(t,n,e){var o=e(14),r=e(4);t.exports=function(t){if(!o(t)||!r(t,"Object"))return!1;if(null===Object.getPrototypeOf(t))return!0;for(var n=t;null!==Object.getPrototypeOf(n);)n=Object.getPrototypeOf(n);return Object.getPrototypeOf(t)===n}},16:function(t,n){t.exports=function(t,n){if(t["_wrap_"+n])return t["_wrap_"+n];var e=function(e){t[n](e)};return t["_wrap_"+n]=e,e}},2:function(t,n,e){var o=e(15),r=e(3),i=5;function u(t,n,e,f){for(var c in e=e||0,f=f||i,n)if(n.hasOwnProperty(c)){var s=n[c];null!==s&&o(s)?(o(t[c])||(t[c]={}),e<f?u(t[c],s,e+1,f):t[c]=n[c]):r(s)?(t[c]=[],t[c]=t[c].concat(s)):void 0!==s&&(t[c]=s)}}t.exports=function(){for(var t=new Array(arguments.length),n=t.length,e=0;e<n;e++)t[e]=arguments[e];for(var o=t[0],r=1;r<n;r++)u(o,t[r]);return o}},3:function(t,n,e){var o=e(4),r=Array.isArray?Array.isArray:function(t){return o(t,"Array")};t.exports=r},4:function(t,n){var e={}.toString;t.exports=function(t,n){return e.call(t)==="[object "+n+"]"}},40:function(t,n,e){var o=e(8),r=e(9),i=function(t){function n(){return t.apply(this,arguments)||this}!function(t,n){t.prototype=Object.create(n.prototype),t.prototype.constructor=t,t.__proto__=n}(n,t);var e=n.prototype;return e.getDefaultCfgs=function(){return{createDOM:!0,container:null,className:"g6-analyzer-menu",getContent:null,onShow:function(){},onHide:function(){}}},e.getEvents=function(){return{contextmenu:"onMenuShow"}},e.init=function(){if(this.get("createDOM")){var t=document.createElement("div");t.className=this.get("className"),r(t,{visibility:"hidden"});var n=this.get("container");n||(n=this.get("graph").get("container")),n.appendChild(t),this.set("menu",t)}},e.onMenuShow=function(t){var n=this,e=this.get("menu"),o=this.get("getContent"),i=this.get("onShow");if(o&&(e.innerHTML=o(t)),e){var u=this.get("graph"),f=u.get("width"),c=u.get("height"),s=e.getBoundingClientRect(),a=t.canvasX,l=t.canvasY;a+s.width>f&&(a=f-s.width,t.canvasX=a),l+s.height>c&&(l=c-s.height,t.canvasY=l),i&&!1===i(t)||r(e,{top:l,left:a,visibility:"visible"})}else i(t);var p=function(){n.onMenuHide()};document.body.addEventListener("click",p),this.set("handler",p)},e.onMenuHide=function(){var t=this.get("menu");!1!==this.get("onHide")()&&(t&&r(t,{visibility:"hidden"}),document.body.removeEventListener("click",this.get("handler")))},e.destroy=function(){var t=this.get("menu"),n=this.get("handler");t&&t.parentNode.removeChild(t),n&&document.body.removeEventListener("click",n)},n}(o);t.exports=i},7:function(t,n,e){var o=e(12),r=e(3);t.exports=function(t,n){if(t)if(r(t))for(var e=0,i=t.length;e<i&&!1!==n(t[e],e);e++);else if(o(t))for(var u in t)if(t.hasOwnProperty(u)&&!1===n(t[u],u))break}},8:function(t,n,e){var o=e(2),r=e(7),i=e(16),u=function(){function t(t){this._cfgs=o(this.getDefaultCfgs(),t)}var n=t.prototype;return n.getDefaultCfgs=function(){return{}},n.initPlugin=function(t){var n=this;n.set("graph",t);var e=n.getEvents(),o={};r(e,function(e,r){var u=i(n,e);o[r]=u,t.on(r,u)}),this._events=o,this.init()},n.init=function(){},n.getEvents=function(){return{}},n.get=function(t){return this._cfgs[t]},n.set=function(t,n){this._cfgs[t]=n},n.destroy=function(){},n.destroyPlugin=function(){this.destroy();var t=this.get("graph"),n=this._events;r(n,function(n,e){t.off(e,n)}),this._events=null,this._cfgs=null,this.destroyed=!0},t}();t.exports=u},9:function(t,n){t.exports=function(t,n){if(t)for(var e in n)n.hasOwnProperty(e)&&(t.style[e]=n[e]);return t}}})}); //# sourceMappingURL=menu.js.map