new slideRatio option for Control.Pan and Control.PanPanel. r=bartvde (closes #3039)
git-svn-id: http://svn.openlayers.org/trunk/openlayers@11070 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -20,10 +20,20 @@ OpenLayers.Control.Pan = OpenLayers.Class(OpenLayers.Control, {
|
||||
/**
|
||||
* APIProperty: slideFactor
|
||||
* {Integer} Number of pixels by which we'll pan the map in any direction
|
||||
* on clicking the arrow buttons, defaults to 50.
|
||||
* on clicking the arrow buttons, defaults to 50. If you want to pan
|
||||
* by some ratio of the map dimensions, use <slideRatio> instead.
|
||||
*/
|
||||
slideFactor: 50,
|
||||
|
||||
/**
|
||||
* APIProperty: slideRatio
|
||||
* {Number} The fraction of map width/height by which we'll pan the map
|
||||
* on clicking the arrow buttons. Default is null. If set, will
|
||||
* override <slideFactor>. E.g. if slideRatio is .5, then Pan Up will
|
||||
* pan up half the map height.
|
||||
*/
|
||||
slideRatio: null,
|
||||
|
||||
/**
|
||||
* Property: direction
|
||||
* {String} in {'North', 'South', 'East', 'West'}
|
||||
@@ -61,18 +71,24 @@ OpenLayers.Control.Pan = OpenLayers.Class(OpenLayers.Control, {
|
||||
*/
|
||||
trigger: function(){
|
||||
|
||||
var getSlideFactor = OpenLayers.Function.bind(function (dim) {
|
||||
return this.slideRatio ?
|
||||
this.map.getSize()[dim] * this.slideRatio :
|
||||
this.slideFactor;
|
||||
}, this);
|
||||
|
||||
switch (this.direction) {
|
||||
case OpenLayers.Control.Pan.NORTH:
|
||||
this.map.pan(0, -this.slideFactor);
|
||||
this.map.pan(0, -getSlideFactor("h"));
|
||||
break;
|
||||
case OpenLayers.Control.Pan.SOUTH:
|
||||
this.map.pan(0, this.slideFactor);
|
||||
this.map.pan(0, getSlideFactor("h"));
|
||||
break;
|
||||
case OpenLayers.Control.Pan.WEST:
|
||||
this.map.pan(-this.slideFactor, 0);
|
||||
this.map.pan(-getSlideFactor("w"), 0);
|
||||
break;
|
||||
case OpenLayers.Control.Pan.EAST:
|
||||
this.map.pan(this.slideFactor, 0);
|
||||
this.map.pan(getSlideFactor("w"), 0);
|
||||
break;
|
||||
}
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user