diff --git a/graph.min.mjs b/graph.min.mjs index 87c784e..89dec4d 100644 --- a/graph.min.mjs +++ b/graph.min.mjs @@ -32,7 +32,7 @@ import t from"https://cdn.skypack.dev/victor@1.1.0"; * // Initializing edges * instance.edge(new edge(feet, bebra)); */ -export default class core{#t;get shell(){return this.#t}#e;get left(){return this.#e}#s;get top(){return this.#s}#i=new Set;get nodes(){return this.#i}#o=new Set;get edges(){return this.#o}interactions={moving:{graph:{active:!0,inertion:{active:!0}},nodes:{active:!0,inertion:{active:!0}}},pushing:{active:!0,iterations:{from:0,to:100},cascade:{depth:3}},pulling:{active:!0,iterations:{from:0,to:100},cascade:{depth:3}}};#n;set living(t){if("number"==typeof t||void 0===t){this.#n=t,clearInterval(this.#r.get("living"));const e=this;"number"==typeof this.#n&&0!==this.#n&&this.#r.set("living",setInterval((()=>{for(const t of this.#i)t.push(e.interactions.pushing.cascade.depth,e.nodes),t.pull(e.interactions.pulling.cascade.depth)}),this.#n))}}get living(){return this.#n}#a=!1;set camera(t){if("boolean"==typeof t)if(this.#a=t,this.#a){this.#t.ondragstart=this.#t.onselectstart=null;const t=this;document.removeEventListener("mousedown",this.#l.get("camera.start")),this.#l.set("camera.start",(e=>{if(e.target===t.#t||!t.#t.contains(event.target)){const s=e.pageX-t.#t.offsetLeft+pageXOffset,i=e.pageY-t.#t.offsetTop+pageYOffset;document.removeEventListener("mousemove",t.#l.get("camera.moving")),this.#l.set("camera.moving",(e=>{t.#e=e.pageX-s,t.#s=e.pageY-i,t.variables.get("left").active&&t.#t.style.setProperty("--graph-shell-left",t.#e+t.variables.get("left").type),t.variables.get("top").active&&t.#t.style.setProperty("--graph-shell-top",t.#s+t.variables.get("top").type)})),document.addEventListener("mousemove",t.#l.get("camera.moving"))}})),document.addEventListener("mousedown",this.#l.get("camera.start")),document.removeEventListener("mouseup",this.#l.get("camera.end")),this.#l.set("camera.end",(e=>{document.removeEventListener("mousemove",t.#l.get("camera.moving"))})),document.addEventListener("mouseup",this.#l.get("camera.end"))}else document.removeEventListener("mousedown",this.#l.get("camera.start")),document.removeEventListener("mouseup",this.#l.get("camera.end")),document.removeEventListener("mousemove",this.#l.get("camera.moving"))}get camera(){return this.#a}#h=!1;set operate(t){if("boolean"==typeof t)if(this.#h=t,this.#h)for(const t of this.#i)t.activate(this);else for(const t of this.#i)t.deactivate()}get operate(){return this.#h}variables=new Map([["left",{active:!0,type:"px"}],["top",{active:!0,type:"px"}]]);#l=new Map;#r=new Map;constructor(t){t instanceof HTMLElement&&(this.#t=t,this.#t.ondragstart=this.#t.onselectstart=null)}node(t){return t instanceof node&&(t.move(this.#t.offsetWidth/2-t.augmented/2+500*(.5-Math.random()),this.#t.offsetHeight/2-t.augmented/2+500*(.5-Math.random())),this.#i.add(t),this.#h&&t.activate(this),t)}edge(t){return t instanceof edge&&this.#t instanceof HTMLElement&&t.shell instanceof SVGElement&&(this.#t.appendChild(t.shell),this.#o.add(t),t)}} +export class core{#t;get shell(){return this.#t}#e;get left(){return this.#e}#s;get top(){return this.#s}#i=new Set;get nodes(){return this.#i}#o=new Set;get edges(){return this.#o}interactions={moving:{graph:{active:!0,inertion:{active:!0}},nodes:{active:!0,inertion:{active:!0}}},pushing:{active:!0,iterations:{from:0,to:100},cascade:{depth:3}},pulling:{active:!0,iterations:{from:0,to:100},cascade:{depth:3}}};#n;set living(t){if("number"==typeof t||void 0===t){this.#n=t,clearInterval(this.#r.get("living"));const e=this;"number"==typeof this.#n&&0!==this.#n&&this.#r.set("living",setInterval((()=>{for(const t of this.#i)t.push(e.interactions.pushing.cascade.depth,e.nodes),t.pull(e.interactions.pulling.cascade.depth)}),this.#n))}}get living(){return this.#n}#a=!1;set camera(t){if("boolean"==typeof t)if(this.#a=t,this.#a){this.#t.ondragstart=this.#t.onselectstart=null;const t=this;document.removeEventListener("mousedown",this.#l.get("camera.start")),this.#l.set("camera.start",(e=>{if(e.target===t.#t||!t.#t.contains(event.target)){const s=e.pageX-t.#t.offsetLeft+pageXOffset,i=e.pageY-t.#t.offsetTop+pageYOffset;document.removeEventListener("mousemove",t.#l.get("camera.moving")),this.#l.set("camera.moving",(e=>{t.#e=e.pageX-s,t.#s=e.pageY-i,t.variables.get("left").active&&t.#t.style.setProperty("--graph-shell-left",t.#e+t.variables.get("left").type),t.variables.get("top").active&&t.#t.style.setProperty("--graph-shell-top",t.#s+t.variables.get("top").type)})),document.addEventListener("mousemove",t.#l.get("camera.moving"))}})),document.addEventListener("mousedown",this.#l.get("camera.start")),document.removeEventListener("mouseup",this.#l.get("camera.end")),this.#l.set("camera.end",(e=>{document.removeEventListener("mousemove",t.#l.get("camera.moving"))})),document.addEventListener("mouseup",this.#l.get("camera.end"))}else document.removeEventListener("mousedown",this.#l.get("camera.start")),document.removeEventListener("mouseup",this.#l.get("camera.end")),document.removeEventListener("mousemove",this.#l.get("camera.moving"))}get camera(){return this.#a}#h=!1;set operate(t){if("boolean"==typeof t)if(this.#h=t,this.#h)for(const t of this.#i)t.activate(this);else for(const t of this.#i)t.deactivate()}get operate(){return this.#h}variables=new Map([["left",{active:!0,type:"px"}],["top",{active:!0,type:"px"}]]);#l=new Map;#r=new Map;constructor(t){t instanceof HTMLElement&&(this.#t=t,this.#t.ondragstart=this.#t.onselectstart=null)}node(t){return t instanceof node&&(t.move(this.#t.offsetWidth/2-t.augmented/2+500*(.5-Math.random()),this.#t.offsetHeight/2-t.augmented/2+500*(.5-Math.random())),this.#i.add(t),this.#h&&t.activate(this),t)}edge(t){return t instanceof edge&&this.#t instanceof HTMLElement&&t.shell instanceof SVGElement&&(this.#t.appendChild(t.shell),this.#o.add(t),t)}} /** * @name Node *