From 82da43af355acff9d7488454899d91742c9fed50 Mon Sep 17 00:00:00 2001 From: Frederic Junod Date: Wed, 8 Nov 2017 11:38:07 +0100 Subject: [PATCH 1/2] Use getAnimating and getInteracting from ol.View --- src/ol/interaction/dragpan.js | 2 +- src/ol/interaction/modify.js | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/ol/interaction/dragpan.js b/src/ol/interaction/dragpan.js index 10ecb8e87c..c11b23a55e 100644 --- a/src/ol/interaction/dragpan.js +++ b/src/ol/interaction/dragpan.js @@ -151,7 +151,7 @@ ol.interaction.DragPan.handleDownEvent_ = function(mapBrowserEvent) { view.setHint(ol.ViewHint.INTERACTING, 1); } // stop any current animation - if (view.getHints()[ol.ViewHint.ANIMATING]) { + if (view.getAnimating()) { view.setCenter(mapBrowserEvent.frameState.viewState.center); } if (this.kinetic_) { diff --git a/src/ol/interaction/modify.js b/src/ol/interaction/modify.js index 73856fbd93..6b070c9278 100644 --- a/src/ol/interaction/modify.js +++ b/src/ol/interaction/modify.js @@ -6,7 +6,6 @@ goog.require('ol.CollectionEventType'); goog.require('ol.Feature'); goog.require('ol.MapBrowserEventType'); goog.require('ol.MapBrowserPointerEvent'); -goog.require('ol.ViewHint'); goog.require('ol.array'); goog.require('ol.coordinate'); goog.require('ol.events'); @@ -804,7 +803,7 @@ ol.interaction.Modify.handleEvent = function(mapBrowserEvent) { this.lastPointerEvent_ = mapBrowserEvent; var handled; - if (!mapBrowserEvent.map.getView().getHints()[ol.ViewHint.INTERACTING] && + if (!mapBrowserEvent.map.getView().getInteracting() && mapBrowserEvent.type == ol.MapBrowserEventType.POINTERMOVE && !this.handlingDownUpSequence) { this.handlePointerMove_(mapBrowserEvent); From 0d01a4ca0fea36cd6317e093a1b7a8f03cfbf36f Mon Sep 17 00:00:00 2001 From: Frederic Junod Date: Wed, 8 Nov 2017 11:45:23 +0100 Subject: [PATCH 2/2] Don't use getHints if it's not needed memory optimization: `getHints` creates a copy of the hints array. --- src/ol/view.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ol/view.js b/src/ol/view.js index ddfefe4a35..a51be2199c 100644 --- a/src/ol/view.js +++ b/src/ol/view.js @@ -341,7 +341,7 @@ ol.View.prototype.animate = function(var_args) { * @api */ ol.View.prototype.getAnimating = function() { - return this.getHints()[ol.ViewHint.ANIMATING] > 0; + return this.hints_[ol.ViewHint.ANIMATING] > 0; }; @@ -351,7 +351,7 @@ ol.View.prototype.getAnimating = function() { * @api */ ol.View.prototype.getInteracting = function() { - return this.getHints()[ol.ViewHint.INTERACTING] > 0; + return this.hints_[ol.ViewHint.INTERACTING] > 0; }; @@ -360,7 +360,7 @@ ol.View.prototype.getInteracting = function() { * @api */ ol.View.prototype.cancelAnimations = function() { - this.setHint(ol.ViewHint.ANIMATING, -this.getHints()[ol.ViewHint.ANIMATING]); + this.setHint(ol.ViewHint.ANIMATING, -this.hints_[ol.ViewHint.ANIMATING]); for (var i = 0, ii = this.animations_.length; i < ii; ++i) { var series = this.animations_[i]; if (series[0].callback) {