|
143 | 143 | .on('tick', simulationUpdate); |
144 | 144 |
|
145 | 145 | panzoomInstance = panzoom(svg, { |
146 | | - onClick: (e) => { |
147 | | - e.preventDefault(); |
148 | | -
|
149 | | - // Handle only path elements |
150 | | -
|
151 | | - const el = e.target as SVGPathElement; |
152 | | -
|
153 | | - if (el.tagName !== 'path') return; |
154 | | -
|
155 | | - // alert(`You clicked: ${el.getAttribute('name')}`); |
156 | | -
|
157 | | - // const bounds = el.getBoundingClientRect(); |
158 | | - const bounds = el.getBBox(); |
159 | | -
|
160 | | - const midX = bounds.x + bounds.width / 2; |
161 | | - const midY = bounds.y + bounds.height / 2; |
162 | | -
|
163 | | - console.log(midX, midY); |
164 | | - } |
| 146 | + // onClick: (e) => { |
| 147 | + // e.preventDefault(); |
| 148 | + // // Handle only path elements |
| 149 | + // const el = e.target as SVGPathElement; |
| 150 | + // if (el.tagName !== 'path') return; |
| 151 | + // // const bounds = el.getBBox(); |
| 152 | + // // const midX = bounds.x + bounds.width / 2; |
| 153 | + // // const midY = bounds.y + bounds.height / 2; |
| 154 | + // // console.log(midX, midY); |
| 155 | + // } |
165 | 156 | }); |
166 | 157 |
|
167 | | - console.log(imgEl); |
168 | | - let data: Record<string, { x: number; y: number }> = {}; |
169 | | - document.querySelectorAll<SVGPathElement>('#map path').forEach((path) => { |
170 | | - // Get middle point of each path |
171 | | - const bounds = path.getBBox(); |
172 | | - const midX = bounds.x + bounds.width / 2; |
173 | | - const midY = bounds.y + bounds.height / 2; |
| 158 | + // let data: Record<string, { x: number; y: number }> = {}; |
| 159 | + // document.querySelectorAll<SVGPathElement>('#map path').forEach((path) => { |
| 160 | + // // Get middle point of each path |
| 161 | + // const bounds = path.getBBox(); |
| 162 | + // const midX = bounds.x + bounds.width / 2; |
| 163 | + // const midY = bounds.y + bounds.height / 2; |
174 | 164 |
|
175 | | - console.log(path.getAttribute('name'), midX, midY); |
| 165 | + // console.log(path.getAttribute('name'), midX, midY); |
176 | 166 |
|
177 | | - // data[path.getAttribute('id')!] = { x: midX, y: midY, w: bounds.width, h: bounds.height }; |
178 | | - }); |
| 167 | + // // data[path.getAttribute('id')!] = { x: midX, y: midY, w: bounds.width, h: bounds.height }; |
| 168 | + // }); |
179 | 169 |
|
180 | | - console.log({ data }); |
| 170 | + // console.log({ data }); |
181 | 171 |
|
182 | 172 | setTimeout(() => { |
183 | 173 | simulation.stop(); |
|
0 commit comments