File tree Expand file tree Collapse file tree 5 files changed +20
-4
lines changed
Expand file tree Collapse file tree 5 files changed +20
-4
lines changed Original file line number Diff line number Diff line change 66 name ="{{ graph.properties.name }} "
77 graph ="{{nofloGraph}} "
88 menus ="{{menus}} "
9+ grid ="{{grid}} "
10+ snap ="{{snap}} "
911 width ="{{width}} " height ="{{height}} "
1012 pan ="{{pan}} " scale ="{{scale}} "
1113 autolayout ="{{autolayout}} "
Original file line number Diff line number Diff line change 8888 offsetX : this . props . offsetX
8989 } ;
9090 } ,
91+ getDefaultProps : function ( ) {
92+ return {
93+ snap : TheGraph . config . nodeSize / 2 ,
94+ grid : TheGraph . config . nodeSize
95+ } ;
96+ } ,
9197 zoomFactor : 0 ,
9298 zoomX : 0 ,
9399 zoomY : 0 ,
477483
478484 // Background grid pattern
479485 var scale = this . state . scale ;
480- var g = TheGraph . config . nodeSize * scale ;
486+ var g = this . props . grid * scale ;
481487
482488 var dx = this . state . x % g ;
483489 var dy = this . state . y % g ;
566572 var graphElementOptions = {
567573 graph : this . props . graph ,
568574 scale : this . state . scale ,
575+ grid : this . props . grid ,
576+ snap : this . props . snap ,
569577 app : this ,
570578 library : this . props . library ,
571579 onNodeSelection : this . props . onNodeSelection ,
Original file line number Diff line number Diff line change 194194 } ) ;
195195 } else {
196196 // Snap to grid
197- var snap = TheGraph . config . nodeHeight / 2 ;
197+ var snap = this . props . snap ;
198198 graph . setNodeMetadata ( node . id , {
199199 x : Math . round ( node . metadata . x / snap ) * snap ,
200200 y : Math . round ( node . metadata . y / snap ) * snap
465465 y : node . metadata . y ,
466466 label : node . metadata . label ,
467467 sublabel : node . metadata . sublabel || node . component ,
468+ snap : self . props . snap ,
468469 width : node . metadata . width ,
469470 height : node . metadata . height ,
470471 app : self . props . app ,
Original file line number Diff line number Diff line change 183183
184184 // Snap to grid
185185 var snapToGrid = true ;
186- var snap = TheGraph . config . node . snap / 2 ;
186+ var snap = this . props . snap || TheGraph . config . node . snap / 2 ;
187187 if ( snapToGrid ) {
188188 var x , y ;
189189 if ( this . props . export ) {
Original file line number Diff line number Diff line change 1- < polymer-element name ="the-graph " attributes ="graph menus library width height autolayout theme selectedNodes errorNodes selectedEdges animatedEdges getMenuDef pan scale maxZoom minZoom displaySelectionGroup forceSelection offsetY offsetX " touch-action ="none ">
1+ < polymer-element name ="the-graph " attributes ="graph menus library snap width height autolayout theme selectedNodes errorNodes selectedEdges animatedEdges getMenuDef pan scale maxZoom minZoom displaySelectionGroup forceSelection offsetY offsetX " touch-action ="none ">
22
33
44 < template >
6666 ready : function ( ) {
6767 this . themeChanged ( ) ;
6868 } ,
69+ snapChanged : function ( ) {
70+ this . appView
71+ } ,
6972 themeChanged : function ( ) {
7073 this . $ . svgcontainer . className = "the-graph-" + this . theme ;
7174 } ,
98101 this . appView = ReactDOM . render (
99102 window . TheGraph . App ( {
100103 graph : this . graph ,
104+ grid : this . grid ,
105+ snap : this . snap ,
101106 width : this . width ,
102107 minZoom : this . minZoom ,
103108 maxZoom : this . maxZoom ,
You can’t perform that action at this time.
0 commit comments