make sure scroll only scrolls if it was done over the map, and also stop event propagation so that the window doesnt scroll too

git-svn-id: http://svn.openlayers.org/trunk/openlayers@1246 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
euzuro
2006-08-16 17:24:55 +00:00
parent 2e3ff459b2
commit c2355d207c

View File

@@ -183,24 +183,42 @@ OpenLayers.Control.MouseDefaults.prototype =
* @param {Event} e
*/
onWheelEvent: function(e){
var delta = 0;
if (!e) {
e = window.event;
}
if (e.wheelDelta) {
delta = e.wheelDelta/120;
if (window.opera) {
delta = -delta;
// first determine whether or not the wheeling was inside the map
var inMap = false;
var elem = Event.element(e);
while(elem != null) {
if (elem == this.map.div) {
inMap = true;
break;
}
} else if (e.detail) {
delta = -e.detail / 3;
elem = elem.parentNode;
}
if (delta) {
if (delta < 0) {
this.defaultWheelDown();
} else {
this.defaultWheelUp();
if (inMap) {
var delta = 0;
if (!e) {
e = window.event;
}
if (e.wheelDelta) {
delta = e.wheelDelta/120;
if (window.opera) {
delta = -delta;
}
} else if (e.detail) {
delta = -e.detail / 3;
}
if (delta) {
if (delta < 0) {
this.defaultWheelDown();
} else {
this.defaultWheelUp();
}
}
//only wheel the map, not the window
Event.stop(e);
}
},