|
|
@ -184,8 +184,8 @@ class View { |
|
|
|
if (options.offset === undefined) {options.offset = {x: 0, y: 0}; } |
|
|
|
if (options.offset.x === undefined) {options.offset.x = 0; } |
|
|
|
if (options.offset.y === undefined) {options.offset.y = 0; } |
|
|
|
if (options.scale === undefined) {options.scale = this.body.view.scale; } |
|
|
|
if (options.position === undefined) {options.position = this.body.view.translation;} |
|
|
|
if (options.scale === undefined) {options.scale = this.body.view.scale; } |
|
|
|
if (options.position === undefined) {options.position = this.getViewPosition();} |
|
|
|
if (options.animation === undefined) {options.animation = {duration:0}; } |
|
|
|
if (options.animation === false ) {options.animation = {duration:0}; } |
|
|
|
if (options.animation === true ) {options.animation = {}; } |
|
|
@ -231,6 +231,7 @@ class View { |
|
|
|
// but at least then we'll have the target transition
|
|
|
|
this.body.view.scale = this.targetScale; |
|
|
|
var viewCenter = this.canvas.DOMtoCanvas({x: 0.5 * this.canvas.frame.canvas.clientWidth, y: 0.5 * this.canvas.frame.canvas.clientHeight}); |
|
|
|
console.log('viewCenter', viewCenter,this.body.view.translation, options.position) |
|
|
|
var distanceFromCenter = { // offset from view, distance view has to change by these x and y to center the node
|
|
|
|
x: viewCenter.x - options.position.x, |
|
|
|
y: viewCenter.y - options.position.y |
|
|
@ -326,7 +327,7 @@ class View { |
|
|
|
} |
|
|
|
|
|
|
|
getViewPosition() { |
|
|
|
return {x:this.body.view.translation.x, y:this.body.view.translation.y}; |
|
|
|
return this.canvas.DOMtoCanvas({x: 0.5 * this.canvas.frame.canvas.clientWidth, y: 0.5 * this.canvas.frame.canvas.clientHeight}); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|