From 027dac0d8e46e937e0309d6aa8da6d6e7314aeb3 Mon Sep 17 00:00:00 2001 From: Francesco Cretti Date: Wed, 7 Mar 2018 11:25:33 +0100 Subject: [PATCH] navigato minimap onClick vertical/horizontal pan fix --- src/navigator.js | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/src/navigator.js b/src/navigator.js index 4c9848cf..45b56b6c 100644 --- a/src/navigator.js +++ b/src/navigator.js @@ -405,10 +405,26 @@ $.extend( $.Navigator.prototype, $.EventSource.prototype, $.Viewer.prototype, /* * @function */ function onCanvasClick( event ) { - if ( event.quick && this.viewer.viewport ) { - this.viewer.viewport.panTo(this.viewport.pointFromPixel(event.position)); - this.viewer.viewport.applyConstraints(); + if (event.quick && this.viewer.viewport && (this.panVertical || this.panHorizontal)) { + var target, + posX, + posY; + if (!this.panVertical) { + // perform only horizonal pan + posX = this.viewport.pointFromPixel(event.position).x; + posY = this.viewport.getCenter().y; + target = new $.Point(posX, posY); + } else if (!this.panHorizontal) { + // perform only vertical pan + posX = this.viewport.getCenter().x; + posY = this.viewport.pointFromPixel(event.position).y; + target = new $.Point(posX, posY); + } else { + target = this.viewport.pointFromPixel(event.position); } + this.viewer.viewport.panTo(target); + this.viewer.viewport.applyConstraints(); + } } /**