(
toScale,
zoomOptions,
focal
)
| 284 | } |
| 285 | |
| 286 | function zoom( |
| 287 | toScale, |
| 288 | zoomOptions, |
| 289 | focal |
| 290 | ) { |
| 291 | const result = constrainScale(toScale, zoomOptions) |
| 292 | const zoomScale = result.scale |
| 293 | const zoomOpts = result.opts |
| 294 | if (scale !== zoomScale) { |
| 295 | scale = zoomScale |
| 296 | let toX = x |
| 297 | let toY = y |
| 298 | if (focal) { |
| 299 | const focalX = focal.x || 0 |
| 300 | const focalY = focal.y || 0 |
| 301 | const diffScale = zoomScale / scale |
| 302 | toX = focalX - (focalX - x) * diffScale |
| 303 | toY = focalY - (focalY - y) * diffScale |
| 304 | } |
| 305 | return pan(toX, toY, zoomOpts, zoomOptions.originalEvent) |
| 306 | } |
| 307 | return { x, y, scale, isSVG: isSVGElement(elem), originalEvent: zoomOptions.originalEvent } |
| 308 | } |
| 309 | |
| 310 | function zoomIn(zoomOptions) { |
| 311 | zoom(scale + options.step, zoomOptions) |
no test coverage detected