MCPcopy Create free account
hub / github.com/PaulleDemon/PyUIBuilder / zoom

Function zoom

src/components/utils/panzoom.js:286–308  ·  view source on GitHub ↗
(
    toScale,
    zoomOptions,
    focal
  )

Source from the content-addressed store, hash-verified

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)

Callers 7

PanzoomFunction · 0.85
zoomInFunction · 0.85
zoomOutFunction · 0.85
zoomToPointFunction · 0.85
zoomWithWheelFunction · 0.85
handleMoveFunction · 0.85
resetFunction · 0.85

Calls 2

constrainScaleFunction · 0.85
panFunction · 0.85

Tested by

no test coverage detected