reuse move function

This commit is contained in:
Zutatensuppe 2021-04-17 19:35:32 +02:00
parent 34c58dcd71
commit 7cfc1915a4

View file

@ -20,14 +20,12 @@ export default class Camera {
return false
}
const zoomToCoord = viewportCoordCenter
const zoomFactor = (1 / this.zoom) - (1 / zoom)
this.x -= Math.round(zoomToCoord.x * zoomFactor)
this.y -= Math.round(zoomToCoord.y * zoomFactor)
const zoomFactor = 1 - (this.zoom / zoom)
this.move(
-viewportCoordCenter.x * zoomFactor,
-viewportCoordCenter.y * zoomFactor,
)
this.zoom = zoom
return true
}