Change previous_ local variable type to boolean

And rename it to pressed_ for clarity; the variable represents whether
the mouse button is pressed
This commit is contained in:
Frederic Junod
2013-08-27 14:34:34 +02:00
parent 9306704c1d
commit dc5b209f7f

View File

@@ -124,10 +124,11 @@ ol.MapBrowserEventHandler = function(map) {
this.map_ = map;
/**
* @type {Object}
* Whether one of the mouse button is pressed.
* @type {boolean}
* @private
*/
this.previous_ = null;
this.pressed_ = false;
/**
* @type {boolean}
@@ -231,11 +232,11 @@ ol.MapBrowserEventHandler.prototype.click_ = function(browserEvent) {
* @private
*/
ol.MapBrowserEventHandler.prototype.handleMouseUp_ = function(browserEvent) {
if (this.previous_) {
if (this.pressed_) {
this.down_ = null;
goog.array.forEach(this.dragListenerKeys_, goog.events.unlistenByKey);
this.dragListenerKeys_ = null;
this.previous_ = null;
this.pressed_ = false;
if (this.dragged_) {
var newEvent = new ol.MapBrowserEvent(
ol.MapBrowserEvent.EventType.DRAGEND, this.map_, browserEvent);
@@ -253,12 +254,9 @@ ol.MapBrowserEventHandler.prototype.handleMouseDown_ = function(browserEvent) {
var newEvent = new ol.MapBrowserEvent(
ol.MapBrowserEvent.EventType.DOWN, this.map_, browserEvent);
this.dispatchEvent(newEvent);
if (!this.previous_) {
if (!this.pressed_) {
this.down_ = browserEvent;
this.previous_ = {
clientX: browserEvent.clientX,
clientY: browserEvent.clientY
};
this.pressed_ = true;
this.dragged_ = false;
this.dragListenerKeys_ = [
goog.events.listen(goog.global.document, goog.events.EventType.MOUSEMOVE,
@@ -284,10 +282,6 @@ ol.MapBrowserEventHandler.prototype.handleMouseMove_ = function(browserEvent) {
ol.MapBrowserEvent.EventType.DRAGSTART, this.map_, this.down_);
this.dispatchEvent(newEvent);
}
this.previous_ = {
clientX: browserEvent.clientX,
clientY: browserEvent.clientY
};
newEvent = new ol.MapBrowserEvent(
ol.MapBrowserEvent.EventType.DRAG, this.map_, browserEvent);
this.dispatchEvent(newEvent);