scrolling with mousewheel triggers zooming.
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1215 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -19,6 +19,14 @@ OpenLayers.Control.MouseDefaults.prototype =
|
||||
*/
|
||||
initialize: function() {
|
||||
OpenLayers.Control.prototype.initialize.apply(this, arguments);
|
||||
|
||||
//register mousewheel events specifically on the window and document
|
||||
Event.observe(window, "DOMMouseScroll",
|
||||
this.onWheelEvent.bindAsEventListener(this));
|
||||
Event.observe(window, "mousewheel",
|
||||
this.onWheelEvent.bindAsEventListener(this));
|
||||
Event.observe(document, "mousewheel",
|
||||
this.onWheelEvent.bindAsEventListener(this));
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -148,6 +156,54 @@ OpenLayers.Control.MouseDefaults.prototype =
|
||||
this.defaultMouseUp(evt);
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
/** User spun scroll wheel up
|
||||
*
|
||||
*/
|
||||
defaultWheelUp: function() {
|
||||
this.map.zoomIn();
|
||||
},
|
||||
|
||||
/** User spun scroll wheel down
|
||||
*
|
||||
*/
|
||||
defaultWheelDown: function() {
|
||||
this.map.zoomOut();
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* Mouse ScrollWheel code thanks to http://adomas.org/javascript-mouse-wheel/
|
||||
*/
|
||||
|
||||
|
||||
/** Catch the wheel event and handle it xbrowserly
|
||||
*
|
||||
* @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;
|
||||
}
|
||||
} else if (e.detail) {
|
||||
delta = -e.detail / 3;
|
||||
}
|
||||
if (delta) {
|
||||
if (delta < 0) {
|
||||
this.map.zoomOut();
|
||||
} else {
|
||||
this.map.zoomIn();
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
/** @final @type String */
|
||||
CLASS_NAME: "OpenLayers.Control.MouseDefaults"
|
||||
|
||||
Reference in New Issue
Block a user