From 8d052c8c4c6eebbef9c3193075121a09edb6d96c Mon Sep 17 00:00:00 2001 From: girify Date: Wed, 5 Nov 2014 21:57:20 -0800 Subject: [PATCH] Added new param "easyPan" Feel free to change the parameter name! This parameter lets user pan the map freely within container. This param can be very useful with setFocus() - Map can zoom properly when region on the edges of border are focused. Credit goes to @brbarnett (https://github.com/bjornd/jvectormap/issues/239) --- src/map.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/map.js b/src/map.js index 5b95aeeb..0febe63a 100644 --- a/src/map.js +++ b/src/map.js @@ -6,6 +6,7 @@ * @param {String} params.backgroundColor Background color of the map in CSS format. * @param {Boolean} params.zoomOnScroll When set to true map could be zoomed using mouse scroll. Default value is true. * @param {Boolean} params.panOnDrag When set to true, the map pans when being dragged. Default value is true. + * @param {Boolean} params.easyPan When set to true, the map can pan freely out of container. Default value is false. * @param {Number} params.zoomMax Indicates the maximum zoom ratio which could be reached zooming the map. Default value is 8. * @param {Number} params.zoomMin Indicates the minimum zoom ratio which could be reached zooming the map. Default value is 1. * @param {Number} params.zoomStep Indicates the multiplier used to zoom map with +/- buttons. Default value is 1.6. @@ -271,14 +272,14 @@ jvm.Map.prototype = { } if (this.transY > maxTransY) { - this.transY = maxTransY; + if (!this.params.easyPan) this.transY = maxTransY; } else if (this.transY < minTransY) { - this.transY = minTransY; + if (!this.params.easyPan) this.transY = minTransY; } if (this.transX > maxTransX) { - this.transX = maxTransX; + if (!this.params.easyPan) this.transX = maxTransX; } else if (this.transX < minTransX) { - this.transX = minTransX; + if (!this.params.easyPan) this.transX = minTransX; } this.canvas.applyTransformParams(this.scale, this.transX, this.transY);