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