[fusion-commits] r1889 - trunk/lib
svn_fusion at osgeo.org
svn_fusion at osgeo.org
Fri Jul 31 12:23:46 EDT 2009
Author: zjames
Date: 2009-07-31 12:23:46 -0400 (Fri, 31 Jul 2009)
New Revision: 1889
Modified:
trunk/lib/Map.js
Log:
re #165: collect new events until timer expires, then set extents
Modified: trunk/lib/Map.js
===================================================================
--- trunk/lib/Map.js 2009-07-29 15:39:45 UTC (rev 1888)
+++ trunk/lib/Map.js 2009-07-31 16:23:46 UTC (rev 1889)
@@ -254,12 +254,27 @@
* evt - {Event}
*/
wheelChange: function(evt, deltaZ) {
+ if (this.wheelTimer) {
+ clearTimeout(this.wheelTimer);
+ } else {
+ this.cumulativeDelta = 0;
+ }
+ this.cumulativeDelta += (deltaZ < 0)?-1:1;
+
+ this.wheelTimer = setTimeout(OpenLayers.Function.bind(function(){this.doWheelChange(evt, deltaZ);}, this), 200);
+ },
+
+ doWheelChange: function(evt, deltaZ) {
+ this.wheelTimer = null;
+ if (this.cumulativeDelta == 0) {
+ return;
+ }
var size = this.oMapOL.getSize();
var deltaX = size.w/2 - evt.xy.x;
var deltaY = evt.xy.y - size.h/2;
- var deltaRes = deltaZ > 0 ? 0.5 : 2; //TODO: use some sort of factor here
- var newRes = this.oMapOL.baseLayer.getResolution()*deltaRes;
+ var deltaRes = this.cumulativeDelta > 0 ? 1/(this.cumulativeDelta+1) : Math.abs(this.cumulativeDelta)+1;
+ var newRes = this.oMapOL.baseLayer.getResolution() * deltaRes;
var zoomPoint = this.oMapOL.getLonLatFromPixel(evt.xy);
var newCenter = new OpenLayers.LonLat(
zoomPoint.lon + deltaX * newRes,
@@ -269,7 +284,6 @@
newCenter.lat - size.h*newRes/2,
newCenter.lon + size.w*newRes/2,
newCenter.lat + size.h*newRes/2);
- //this.wheelDelay = null;
this.setExtents(newBounds);
},
@@ -281,10 +295,6 @@
* evt - {Event}
*/
wheelUp: function(evt) {
- //if (this.wheelDelay) {
- // window.clearTimeout(this.wheelDelay);
- //}
- //this.wheelDelay = window.setTimeout(OpenLayers.Function.bind(this.wheelChange, this, evt, 1),200);
this.wheelChange(evt, 1);
},
@@ -296,10 +306,6 @@
* evt - {Event}
*/
wheelDown: function(evt) {
- //if (this.wheelDelay) {
- // window.clearTimeout(this.wheelDelay);
- //}
- //this.wheelDelay = window.setTimeout(OpenLayers.Function.bind(this.wheelChange, this, evt, -1),200);
this.wheelChange(evt, -1);
},
@@ -361,7 +367,6 @@
}
}
this.oMapOL.addLayer(map.oLayerOL);
- console.log('layer added:'+map.oLayerOL.name);
map.registerForEvent(Fusion.Event.MAP_LOADED,
OpenLayers.Function.bind(this.mapLoadHandler, this));
map.registerForEvent(Fusion.Event.MAP_SELECTION_OFF,
More information about the fusion-commits
mailing list