Skip to content
This repository was archived by the owner on Nov 22, 2024. It is now read-only.

Commit 884fc42

Browse files
authored
Merge pull request #421 from irskep/zoom-centering
Zoom center point remains constant
2 parents 8d81c60 + 4863b81 commit 884fc42

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/core/LiterallyCanvas.coffee

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -249,13 +249,13 @@ module.exports = class LiterallyCanvas
249249
@setZoom(newScale)
250250

251251
setZoom: (scale) ->
252+
center = @clientCoordsToDrawingCoords(@canvas.width / 2, @canvas.height / 2)
252253
oldScale = @scale
253254
@scale = scale
254255

255-
@position.x = math.scalePositionScalar(
256-
@position.x, @canvas.width, oldScale, @scale)
257-
@position.y = math.scalePositionScalar(
258-
@position.y, @canvas.height, oldScale, @scale)
256+
@position.x = @canvas.width / 2 * @backingScale - center.x * @getRenderScale()
257+
@position.y = @canvas.height / 2 * @backingScale - center.y * @getRenderScale()
258+
259259
@keepPanInImageBounds()
260260

261261
@repaintAllLayers()

0 commit comments

Comments
 (0)