diff --git a/src/viewer.js b/src/viewer.js index 49d972db..76b78094 100644 --- a/src/viewer.js +++ b/src/viewer.js @@ -1674,7 +1674,7 @@ $.extend( $.Viewer.prototype, $.EventSource.prototype, $.ControlDock.prototype, onFullScreenHandler = $.delegate( this, onFullScreen ), onRotateLeftHandler = $.delegate( this, onRotateLeft ), onRotateRightHandler = $.delegate( this, onRotateRight ), - onFlipHandler = $.delegate( this, onButtonFlip), + onFlipHandler = $.delegate( this, onFlip), onFocusHandler = $.delegate( this, onFocus ), onBlurHandler = $.delegate( this, onBlur ), navImages = this.navImages, @@ -2636,7 +2636,7 @@ function onCanvasKeyPress( event ) { this.viewport.applyConstraints(); return false; case 102: //f - onFlip(this); + this.viewport.toggleFlip(); return false; default: // console.log( 'navigator keycode %s', event.keyCode ); @@ -3519,24 +3519,11 @@ function onRotateRight() { } } -/** - * Note: When pressed f on keyboard - */ -function onFlip( viewer ){ - viewer.viewport.flipped = !viewer.viewport.flipped; - - if(viewer.navigator){ - viewer.navigator.toggleFlip(); - } - viewer._forceRedraw = !viewer._forceRedraw; - viewer.forceRedraw(); -} - /** * Note: When pressed flip control button */ -function onButtonFlip() { - onFlip(this); +function onFlip() { + this.viewport.toggleFlip(); } function onPrevious(){ diff --git a/src/viewport.js b/src/viewport.js index 95632271..4c30dcee 100644 --- a/src/viewport.js +++ b/src/viewport.js @@ -1519,7 +1519,20 @@ $.Viewport.prototype = { var scale = this._contentBoundsNoRotate.width; var viewportToImageZoomRatio = (imageWidth / containerWidth) / scale; return imageZoom * viewportToImageZoomRatio; + }, + + /** + * Toggle flip state and demands a new drawing on navigator and viewer objects. + */ + toggleFlip: function() { + this.flipped = !this.flipped; + if(this.viewer.navigator){ + this.viewer.navigator.toggleFlip(); + } + this.viewer._forceRedraw = !this.viewer._forceRedraw; + this.viewer.forceRedraw(); } + }; }( OpenSeadragon ));