Fix strange behavor on page resize
This commit is contained in:
		
							parent
							
								
									9dc8ba5526
								
							
						
					
					
						commit
						b926dd3526
					
				
					 1 changed files with 2 additions and 10 deletions
				
			
		|  | @ -75,15 +75,7 @@ | ||||||
|   // start simulation and center view on create |   // start simulation and center view on create | ||||||
|   onMount(() => { |   onMount(() => { | ||||||
|     // set center of the SVG at (0,0) |     // set center of the SVG at (0,0) | ||||||
|     let svg = d3 |     let svg = d3.select(svgElement) | ||||||
|       .select(svgElement) |  | ||||||
|       .attr("viewBox", [ |  | ||||||
|         -clientWidth / 2, |  | ||||||
|         -clientHeight / 2, |  | ||||||
|         clientWidth, |  | ||||||
|         clientHeight, |  | ||||||
|       ]) |  | ||||||
|       .select("g"); |  | ||||||
| 
 | 
 | ||||||
|     // setup zoom |     // setup zoom | ||||||
|     function zoomed(e) { |     function zoomed(e) { | ||||||
|  | @ -118,7 +110,7 @@ | ||||||
| </style> | </style> | ||||||
| 
 | 
 | ||||||
| <div bind:this={container} bind:clientHeight bind:clientWidth> | <div bind:this={container} bind:clientHeight bind:clientWidth> | ||||||
|   <svg bind:this={svgElement}> |   <svg bind:this={svgElement} viewBox="{-clientWidth / 2},{-clientHeight / 2},{clientWidth},{clientHeight}"> | ||||||
|     <g> |     <g> | ||||||
|       {#each edges as edge} |       {#each edges as edge} | ||||||
|         <GraphEdge {edge} /> |         <GraphEdge {edge} /> | ||||||
|  |  | ||||||
		Reference in a new issue