New MapHandler base class; better API docs
This commit is contained in:
@@ -2,44 +2,33 @@
|
||||
* @fileoverview Mouse Wheel Handler.
|
||||
*
|
||||
* Provides a class for listening to mousewheel events on a DOM element
|
||||
* and re-dispatching to a map instance.
|
||||
* and dispatching mousewheel events to a map instance.
|
||||
*
|
||||
* The default behabior is zooming the map.
|
||||
* The default behavior for the mousewheel event is zooming the map.
|
||||
*/
|
||||
|
||||
goog.provide('ol.handler.MouseWheel');
|
||||
|
||||
goog.require('ol.handler.states');
|
||||
goog.require('ol.handler.MapHandler');
|
||||
goog.require('ol.events.MapEvent');
|
||||
goog.require('ol.events.MapEventType');
|
||||
|
||||
goog.require('goog.asserts');
|
||||
goog.require('goog.events');
|
||||
goog.require('goog.style');
|
||||
goog.require('goog.Disposable');
|
||||
goog.require('goog.events.MouseWheelHandler');
|
||||
goog.require('goog.events.MouseWheelHandler.EventType');
|
||||
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends {goog.Disposable}
|
||||
* @extends {ol.handler.MapHandler}
|
||||
* @param {ol.Map} map The map instance.
|
||||
* @param {Element} element The element we listen to mousewheel on.
|
||||
* @param {Object} states An object for the handlers to share states.
|
||||
* @param {Element} element The element we listen for click on.
|
||||
* @param {ol.handler.states} states An object for the handlers to share
|
||||
* states.
|
||||
*/
|
||||
ol.handler.MouseWheel = function(map, element, states) {
|
||||
goog.base(this);
|
||||
|
||||
/**
|
||||
* @type {ol.Map}
|
||||
*/
|
||||
this.map_ = map;
|
||||
|
||||
/**
|
||||
* @type {Element}
|
||||
*/
|
||||
this.element_ = element;
|
||||
goog.base(this, map, element, states);
|
||||
|
||||
var handler = new goog.events.MouseWheelHandler(element);
|
||||
this.registerDisposable(handler);
|
||||
@@ -49,7 +38,7 @@ ol.handler.MouseWheel = function(map, element, states) {
|
||||
this.handleMouseWheel, false, this);
|
||||
|
||||
};
|
||||
goog.inherits(ol.handler.MouseWheel, goog.Disposable);
|
||||
goog.inherits(ol.handler.MouseWheel, ol.handler.MapHandler);
|
||||
|
||||
/**
|
||||
* @param {goog.events.MouseWheelEvent} e
|
||||
@@ -58,14 +47,14 @@ ol.handler.MouseWheel.prototype.handleMouseWheel = function(e) {
|
||||
var newE = new ol.events.MapEvent(ol.events.MapEventType.MOUSEWHEEL, e);
|
||||
var rt = goog.events.dispatchEvent(this.map_, newE);
|
||||
if (rt) {
|
||||
this.defaultBehavior(e);
|
||||
this.defaultMouseWheel(e);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {goog.events.MouseWheelEvent} e
|
||||
*/
|
||||
ol.handler.MouseWheel.prototype.defaultBehavior = function(e) {
|
||||
ol.handler.MouseWheel.prototype.defaultMouseWheel = function(e) {
|
||||
var me = this;
|
||||
if (e.deltaY === 0 || me.zoomBlocked_) {
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user