reuse move function
This commit is contained in:
parent
34c58dcd71
commit
7cfc1915a4
1 changed files with 5 additions and 7 deletions
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue