@ -150,12 +150,29 @@ class NavigationHandler {
_moveDown ( ) { this . body . view . translation . y -= this . options . keyboard . speed . y ; }
_moveLeft ( ) { this . body . view . translation . x += this . options . keyboard . speed . x ; }
_moveRight ( ) { this . body . view . translation . x -= this . options . keyboard . speed . x ; }
_zoomIn ( ) {
this . body . view . scale *= 1 + this . options . keyboard . speed . zoom ;
this . body . emitter . emit ( 'zoom' , { direction : '+' , scale : this . body . view . scale } ) ; }
_zoomIn ( ) {
var scaleOld = this . body . view . scale ;
var scale = this . body . view . scale * ( 1 + this . options . keyboard . speed . zoom ) ;
var translation = this . body . view . translation ;
var scaleFrac = scale / scaleOld ;
var tx = ( 1 - scaleFrac ) * this . canvas . canvasViewCenter . x + translation . x * scaleFrac ;
var ty = ( 1 - scaleFrac ) * this . canvas . canvasViewCenter . y + translation . y * scaleFrac ;
this . body . view . scale = scale ;
this . body . view . translation = { x : tx , y : ty } ;
this . body . emitter . emit ( 'zoom' , { direction : '+' , scale : this . body . view . scale } ) ;
}
_zoomOut ( ) {
this . body . view . scale /= 1 + this . options . keyboard . speed . zoom ;
this . body . emitter . emit ( 'zoom' , { direction : '-' , scale : this . body . view . scale } ) ;
var scaleOld = this . body . view . scale ;
var scale = this . body . view . scale / ( 1 + this . options . keyboard . speed . zoom ) ;
var translation = this . body . view . translation ;
var scaleFrac = scale / scaleOld ;
var tx = ( 1 - scaleFrac ) * this . canvas . canvasViewCenter . x + translation . x * scaleFrac ;
var ty = ( 1 - scaleFrac ) * this . canvas . canvasViewCenter . y + translation . y * scaleFrac ;
this . body . view . scale = scale ;
this . body . view . translation = { x : tx , y : ty } ;
this . body . emitter . emit ( 'zoom' , { direction : '-' , scale : this . body . view . scale } ) ;
}