mirror of
https://github.com/overleaf/overleaf.git
synced 2024-12-04 20:54:53 -05:00
1 line
No EOL
1.9 KiB
JavaScript
Executable file
1 line
No EOL
1.9 KiB
JavaScript
Executable file
(function(){"use strict";if("undefined"==typeof sigma)throw"sigma is not declared";sigma.utils.pkg("sigma.plugins"),sigma.plugins.dragNodes=function(a,b){if(sigma.renderers.webgl&&b instanceof sigma.renderers.webgl)throw new Error("The sigma.plugins.dragNodes is not compatible with the WebGL renderer");var c=document.body,d=b.container,e=d.lastChild,f=b.camera,g=null,h="",i=[],j=!1;h=b instanceof sigma.renderers.webgl?b.options.prefix.substr(5):b.options.prefix;var k=function(a){var b=window.getComputedStyle(a),c=function(a){return parseInt(b.getPropertyValue(a).replace("px",""))||0};return{left:a.getBoundingClientRect().left+c("padding-left"),top:a.getBoundingClientRect().top+c("padding-top")}},l=function(a){i.push(a.data.node),i.length&&!j&&(g=i[i.length-1],e.addEventListener("mousedown",n))},m=function(a){var b=i.map(function(a){return a}).indexOf(a.data.node);i.splice(b,1),i.length&&!j?g=i[i.length-1]:e.removeEventListener("mousedown",n)},n=function(){j=!0;var d=a.graph.nodes().length;d>1&&(e.removeEventListener("mousedown",n),c.addEventListener("mousemove",p),c.addEventListener("mouseup",o),b.settings({mouseEnabled:!1,enableHovering:!1}),a.refresh())},o=function(){j=!1,e.addEventListener("mousedown",n),c.removeEventListener("mousemove",p),c.removeEventListener("mouseup",o),b.settings({mouseEnabled:!0,enableHovering:!0}),a.refresh()},p=function(b){function c(){for(var c=k(d),e=b.pageX-c.left,i=b.pageY-c.top,j=Math.cos(f.angle),l=Math.sin(f.angle),m=a.graph.nodes(),n=[],o=0;2>o;o++){var p=m[o],q={x:p.x*j+p.y*l,y:p.y*j-p.x*l,renX:p[h+"x"],renY:p[h+"y"]};n.push(q)}e=(e-n[0].renX)/(n[1].renX-n[0].renX)*(n[1].x-n[0].x)+n[0].x,i=(i-n[0].renY)/(n[1].renY-n[0].renY)*(n[1].y-n[0].y)+n[0].y,g.x=e*j-i*l,g.y=i*j+e*l,a.refresh()}if(navigator.userAgent.toLowerCase().indexOf("firefox")>-1){clearTimeout(e);var e=setTimeout(c,0)}else c()};b.bind("overNode",l),b.bind("outNode",m)}}).call(window); |