Call the callbacks if the cursor is over a div with an 'olScrollable' css class

This commit is contained in:
Frederic Junod
2012-05-31 09:36:28 +02:00
parent 2ff5a7b599
commit b0377b54b0
+13 -9
View File
@@ -101,12 +101,13 @@ OpenLayers.Handler.MouseWheel = OpenLayers.Class(OpenLayers.Handler, {
// Ride up the element's DOM hierarchy to determine if it or any of // Ride up the element's DOM hierarchy to determine if it or any of
// its ancestors was: // its ancestors was:
// * specifically marked as scrollable // * specifically marked as scrollable (CSS overflow property)
// * one of our layer divs // * one of our layer divs or a div marked as scrollable
// ('olScrollable' CSS class)
// * the map div // * the map div
// //
var overScrollableDiv = false; var overScrollableDiv = false;
var overLayerDiv = false; var allowScroll = false;
var overMapDiv = false; var overMapDiv = false;
var elem = OpenLayers.Event.element(e); var elem = OpenLayers.Event.element(e);
@@ -130,18 +131,21 @@ OpenLayers.Handler.MouseWheel = OpenLayers.Class(OpenLayers.Handler, {
} }
} }
if (!overLayerDiv) { if (!allowScroll) {
allowScroll = OpenLayers.Element.hasClass(elem, 'olScrollable');
if (!allowScroll) {
for (var i = 0, len = this.map.layers.length; i < len; i++) { for (var i = 0, len = this.map.layers.length; i < len; i++) {
// Are we in the layer div? Note that we have two cases // Are we in the layer div? Note that we have two cases
// here: one is to catch EventPane layers, which have a // here: one is to catch EventPane layers, which have a
// pane above the layer (layer.pane) // pane above the layer (layer.pane)
if (elem == this.map.layers[i].div var layer = this.map.layers[i];
|| elem == this.map.layers[i].pane) { if (elem == layer.div || elem == layer.pane) {
overLayerDiv = true; allowScroll = true;
break; break;
} }
} }
} }
}
overMapDiv = (elem == this.map.div); overMapDiv = (elem == this.map.div);
elem = elem.parentNode; elem = elem.parentNode;
@@ -154,7 +158,7 @@ OpenLayers.Handler.MouseWheel = OpenLayers.Class(OpenLayers.Handler, {
// //
// otherwise // otherwise
// //
// If we are over the layer div: // If we are over the layer div or a 'olScrollable' div:
// * zoom/in out // * zoom/in out
// then // then
// * kill event (so as not to also scroll the page after zooming) // * kill event (so as not to also scroll the page after zooming)
@@ -165,7 +169,7 @@ OpenLayers.Handler.MouseWheel = OpenLayers.Class(OpenLayers.Handler, {
// layerswitcher or the pan/zoom control) // layerswitcher or the pan/zoom control)
// //
if (!overScrollableDiv && overMapDiv) { if (!overScrollableDiv && overMapDiv) {
if (overLayerDiv) { if (allowScroll) {
var delta = 0; var delta = 0;
if (!e) { if (!e) {
e = window.event; e = window.event;