diff --git a/src/ol/PluggableMap.js b/src/ol/PluggableMap.js index e9a6759f7a..a7022c6997 100644 --- a/src/ol/PluggableMap.js +++ b/src/ol/PluggableMap.js @@ -14,7 +14,7 @@ import _ol_Object_ from './Object.js'; import ObjectEventType from './ObjectEventType.js'; import TileQueue from './TileQueue.js'; import _ol_View_ from './View.js'; -import _ol_ViewHint_ from './ViewHint.js'; +import ViewHint from './ViewHint.js'; import {assert} from './asserts.js'; import {removeNode} from './dom.js'; import _ol_events_ from './events.js'; @@ -954,11 +954,11 @@ PluggableMap.prototype.handlePostRender = function() { var maxNewLoads = maxTotalLoading; if (frameState) { var hints = frameState.viewHints; - if (hints[_ol_ViewHint_.ANIMATING]) { + if (hints[ViewHint.ANIMATING]) { maxTotalLoading = this.loadTilesWhileAnimating_ ? 8 : 0; maxNewLoads = 2; } - if (hints[_ol_ViewHint_.INTERACTING]) { + if (hints[ViewHint.INTERACTING]) { maxTotalLoading = this.loadTilesWhileInteracting_ ? 8 : 0; maxNewLoads = 2; } @@ -1260,8 +1260,8 @@ PluggableMap.prototype.renderFrame_ = function(time) { } var idle = this.previousExtent_ && - !frameState.viewHints[_ol_ViewHint_.ANIMATING] && - !frameState.viewHints[_ol_ViewHint_.INTERACTING] && + !frameState.viewHints[ViewHint.ANIMATING] && + !frameState.viewHints[ViewHint.INTERACTING] && !equals(frameState.extent, this.previousExtent_); if (idle) { diff --git a/src/ol/View.js b/src/ol/View.js index 8475a1012f..eb23dae68e 100644 --- a/src/ol/View.js +++ b/src/ol/View.js @@ -7,7 +7,7 @@ import CenterConstraint from './CenterConstraint.js'; import _ol_Object_ from './Object.js'; import ResolutionConstraint from './ResolutionConstraint.js'; import RotationConstraint from './RotationConstraint.js'; -import _ol_ViewHint_ from './ViewHint.js'; +import ViewHint from './ViewHint.js'; import _ol_ViewProperty_ from './ViewProperty.js'; import {linearFindNearest} from './array.js'; import {assert} from './asserts.js'; @@ -345,7 +345,7 @@ _ol_View_.prototype.animate = function(var_args) { series.push(animation); } this.animations_.push(series); - this.setHint(_ol_ViewHint_.ANIMATING, 1); + this.setHint(ViewHint.ANIMATING, 1); this.updateAnimations_(); }; @@ -356,7 +356,7 @@ _ol_View_.prototype.animate = function(var_args) { * @api */ _ol_View_.prototype.getAnimating = function() { - return this.hints_[_ol_ViewHint_.ANIMATING] > 0; + return this.hints_[ViewHint.ANIMATING] > 0; }; @@ -366,7 +366,7 @@ _ol_View_.prototype.getAnimating = function() { * @api */ _ol_View_.prototype.getInteracting = function() { - return this.hints_[_ol_ViewHint_.INTERACTING] > 0; + return this.hints_[ViewHint.INTERACTING] > 0; }; @@ -375,7 +375,7 @@ _ol_View_.prototype.getInteracting = function() { * @api */ _ol_View_.prototype.cancelAnimations = function() { - this.setHint(_ol_ViewHint_.ANIMATING, -this.hints_[_ol_ViewHint_.ANIMATING]); + this.setHint(ViewHint.ANIMATING, -this.hints_[ViewHint.ANIMATING]); for (var i = 0, ii = this.animations_.length; i < ii; ++i) { var series = this.animations_[i]; if (series[0].callback) { @@ -451,7 +451,7 @@ _ol_View_.prototype.updateAnimations_ = function() { } if (seriesComplete) { this.animations_[i] = null; - this.setHint(_ol_ViewHint_.ANIMATING, -1); + this.setHint(ViewHint.ANIMATING, -1); var callback = series[0].callback; if (callback) { callback(true); diff --git a/src/ol/control/ZoomSlider.js b/src/ol/control/ZoomSlider.js index fb95d51492..75845b816f 100644 --- a/src/ol/control/ZoomSlider.js +++ b/src/ol/control/ZoomSlider.js @@ -4,7 +4,7 @@ // FIXME should possibly show tooltip when dragging? import {inherits} from '../index.js'; -import _ol_ViewHint_ from '../ViewHint.js'; +import ViewHint from '../ViewHint.js'; import Control from '../control/Control.js'; import {CLASS_CONTROL, CLASS_UNSELECTABLE} from '../css.js'; import {easeOut} from '../easing.js'; @@ -251,7 +251,7 @@ ZoomSlider.prototype.handleContainerClick_ = function(event) { */ ZoomSlider.prototype.handleDraggerStart_ = function(event) { if (!this.dragging_ && event.originalEvent.target === this.element.firstElementChild) { - this.getMap().getView().setHint(_ol_ViewHint_.INTERACTING, 1); + this.getMap().getView().setHint(ViewHint.INTERACTING, 1); this.previousX_ = event.clientX; this.previousY_ = event.clientY; this.dragging_ = true; @@ -288,7 +288,7 @@ ZoomSlider.prototype.handleDraggerDrag_ = function(event) { ZoomSlider.prototype.handleDraggerEnd_ = function(event) { if (this.dragging_) { var view = this.getMap().getView(); - view.setHint(_ol_ViewHint_.INTERACTING, -1); + view.setHint(ViewHint.INTERACTING, -1); view.animate({ resolution: view.constrainResolution(this.currentResolution_), diff --git a/src/ol/interaction/DragPan.js b/src/ol/interaction/DragPan.js index 5faba7c016..97220cc018 100644 --- a/src/ol/interaction/DragPan.js +++ b/src/ol/interaction/DragPan.js @@ -2,7 +2,7 @@ * @module ol/interaction/DragPan */ import {inherits} from '../index.js'; -import _ol_ViewHint_ from '../ViewHint.js'; +import ViewHint from '../ViewHint.js'; import _ol_coordinate_ from '../coordinate.js'; import {easeOut} from '../easing.js'; import _ol_events_condition_ from '../events/condition.js'; @@ -123,7 +123,7 @@ DragPan.handleUpEvent_ = function(mapBrowserEvent) { easing: easeOut }); } - view.setHint(_ol_ViewHint_.INTERACTING, -1); + view.setHint(ViewHint.INTERACTING, -1); return false; } else { if (this.kinetic_) { @@ -149,7 +149,7 @@ DragPan.handleDownEvent_ = function(mapBrowserEvent) { var view = map.getView(); this.lastCentroid = null; if (!this.handlingDownUpSequence) { - view.setHint(_ol_ViewHint_.INTERACTING, 1); + view.setHint(ViewHint.INTERACTING, 1); } // stop any current animation if (view.getAnimating()) { diff --git a/src/ol/interaction/DragRotate.js b/src/ol/interaction/DragRotate.js index e96ca44961..5b78c1d761 100644 --- a/src/ol/interaction/DragRotate.js +++ b/src/ol/interaction/DragRotate.js @@ -3,7 +3,7 @@ */ import {inherits} from '../index.js'; import RotationConstraint from '../RotationConstraint.js'; -import _ol_ViewHint_ from '../ViewHint.js'; +import ViewHint from '../ViewHint.js'; import _ol_events_condition_ from '../events/condition.js'; import {FALSE} from '../functions.js'; import Interaction from '../interaction/Interaction.js'; @@ -97,7 +97,7 @@ DragRotate.handleUpEvent_ = function(mapBrowserEvent) { var map = mapBrowserEvent.map; var view = map.getView(); - view.setHint(_ol_ViewHint_.INTERACTING, -1); + view.setHint(ViewHint.INTERACTING, -1); var rotation = view.getRotation(); Interaction.rotate(view, rotation, undefined, this.duration_); @@ -119,7 +119,7 @@ DragRotate.handleDownEvent_ = function(mapBrowserEvent) { if (_ol_events_condition_.mouseActionButton(mapBrowserEvent) && this.condition_(mapBrowserEvent)) { var map = mapBrowserEvent.map; - map.getView().setHint(_ol_ViewHint_.INTERACTING, 1); + map.getView().setHint(ViewHint.INTERACTING, 1); this.lastAngle_ = undefined; return true; } else { diff --git a/src/ol/interaction/DragRotateAndZoom.js b/src/ol/interaction/DragRotateAndZoom.js index 8cb996685d..8846fd5dfc 100644 --- a/src/ol/interaction/DragRotateAndZoom.js +++ b/src/ol/interaction/DragRotateAndZoom.js @@ -3,7 +3,7 @@ */ import {inherits} from '../index.js'; import RotationConstraint from '../RotationConstraint.js'; -import _ol_ViewHint_ from '../ViewHint.js'; +import ViewHint from '../ViewHint.js'; import _ol_events_condition_ from '../events/condition.js'; import Interaction from '../interaction/Interaction.js'; import _ol_interaction_Pointer_ from '../interaction/Pointer.js'; @@ -117,7 +117,7 @@ DragRotateAndZoom.handleUpEvent_ = function(mapBrowserEvent) { var map = mapBrowserEvent.map; var view = map.getView(); - view.setHint(_ol_ViewHint_.INTERACTING, -1); + view.setHint(ViewHint.INTERACTING, -1); var direction = this.lastScaleDelta_ - 1; Interaction.rotate(view, view.getRotation()); Interaction.zoom(view, view.getResolution(), @@ -139,7 +139,7 @@ DragRotateAndZoom.handleDownEvent_ = function(mapBrowserEvent) { } if (this.condition_(mapBrowserEvent)) { - mapBrowserEvent.map.getView().setHint(_ol_ViewHint_.INTERACTING, 1); + mapBrowserEvent.map.getView().setHint(ViewHint.INTERACTING, 1); this.lastAngle_ = undefined; this.lastMagnitude_ = undefined; return true; diff --git a/src/ol/interaction/MouseWheelZoom.js b/src/ol/interaction/MouseWheelZoom.js index 569f707d9b..f0c771d3a0 100644 --- a/src/ol/interaction/MouseWheelZoom.js +++ b/src/ol/interaction/MouseWheelZoom.js @@ -2,7 +2,7 @@ * @module ol/interaction/MouseWheelZoom */ import {inherits} from '../index.js'; -import _ol_ViewHint_ from '../ViewHint.js'; +import ViewHint from '../ViewHint.js'; import condition from '../events/condition.js'; import {easeOut} from '../easing.js'; import EventType from '../events/EventType.js'; @@ -191,7 +191,7 @@ MouseWheelZoom.handleEvent = function(mapBrowserEvent) { if (this.trackpadTimeoutId_) { clearTimeout(this.trackpadTimeoutId_); } else { - view.setHint(_ol_ViewHint_.INTERACTING, 1); + view.setHint(ViewHint.INTERACTING, 1); } this.trackpadTimeoutId_ = setTimeout(this.decrementInteractingHint_.bind(this), this.trackpadEventGap_); var resolution = view.getResolution() * Math.pow(2, delta / this.trackpadDeltaPerZoom_); @@ -256,7 +256,7 @@ MouseWheelZoom.handleEvent = function(mapBrowserEvent) { MouseWheelZoom.prototype.decrementInteractingHint_ = function() { this.trackpadTimeoutId_ = undefined; var view = this.getMap().getView(); - view.setHint(_ol_ViewHint_.INTERACTING, -1); + view.setHint(ViewHint.INTERACTING, -1); }; diff --git a/src/ol/interaction/PinchRotate.js b/src/ol/interaction/PinchRotate.js index ea15683ec5..96170e1b0b 100644 --- a/src/ol/interaction/PinchRotate.js +++ b/src/ol/interaction/PinchRotate.js @@ -2,7 +2,7 @@ * @module ol/interaction/PinchRotate */ import {inherits} from '../index.js'; -import _ol_ViewHint_ from '../ViewHint.js'; +import ViewHint from '../ViewHint.js'; import {FALSE} from '../functions.js'; import Interaction from '../interaction/Interaction.js'; import _ol_interaction_Pointer_ from '../interaction/Pointer.js'; @@ -131,7 +131,7 @@ _ol_interaction_PinchRotate_.handleUpEvent_ = function(mapBrowserEvent) { if (this.targetPointers.length < 2) { var map = mapBrowserEvent.map; var view = map.getView(); - view.setHint(_ol_ViewHint_.INTERACTING, -1); + view.setHint(ViewHint.INTERACTING, -1); if (this.rotating_) { var rotation = view.getRotation(); Interaction.rotate( @@ -158,7 +158,7 @@ _ol_interaction_PinchRotate_.handleDownEvent_ = function(mapBrowserEvent) { this.rotating_ = false; this.rotationDelta_ = 0.0; if (!this.handlingDownUpSequence) { - map.getView().setHint(_ol_ViewHint_.INTERACTING, 1); + map.getView().setHint(ViewHint.INTERACTING, 1); } return true; } else { diff --git a/src/ol/interaction/PinchZoom.js b/src/ol/interaction/PinchZoom.js index 0b0decbc05..c44e88abf4 100644 --- a/src/ol/interaction/PinchZoom.js +++ b/src/ol/interaction/PinchZoom.js @@ -2,7 +2,7 @@ * @module ol/interaction/PinchZoom */ import {inherits} from '../index.js'; -import _ol_ViewHint_ from '../ViewHint.js'; +import ViewHint from '../ViewHint.js'; import {FALSE} from '../functions.js'; import Interaction from '../interaction/Interaction.js'; import _ol_interaction_Pointer_ from '../interaction/Pointer.js'; @@ -125,7 +125,7 @@ _ol_interaction_PinchZoom_.handleUpEvent_ = function(mapBrowserEvent) { if (this.targetPointers.length < 2) { var map = mapBrowserEvent.map; var view = map.getView(); - view.setHint(_ol_ViewHint_.INTERACTING, -1); + view.setHint(ViewHint.INTERACTING, -1); var resolution = view.getResolution(); if (this.constrainResolution_ || resolution < view.getMinResolution() || @@ -157,7 +157,7 @@ _ol_interaction_PinchZoom_.handleDownEvent_ = function(mapBrowserEvent) { this.lastDistance_ = undefined; this.lastScaleDelta_ = 1; if (!this.handlingDownUpSequence) { - map.getView().setHint(_ol_ViewHint_.INTERACTING, 1); + map.getView().setHint(ViewHint.INTERACTING, 1); } return true; } else { diff --git a/src/ol/renderer/canvas/ImageLayer.js b/src/ol/renderer/canvas/ImageLayer.js index ed15bf726b..cb20cccff9 100644 --- a/src/ol/renderer/canvas/ImageLayer.js +++ b/src/ol/renderer/canvas/ImageLayer.js @@ -5,7 +5,7 @@ import {ENABLE_RASTER_REPROJECTION} from '../../reproj/common.js'; import {inherits} from '../../index.js'; import _ol_ImageCanvas_ from '../../ImageCanvas.js'; import LayerType from '../../LayerType.js'; -import _ol_ViewHint_ from '../../ViewHint.js'; +import ViewHint from '../../ViewHint.js'; import {equals} from '../../array.js'; import {getHeight, getIntersection, getWidth, isEmpty} from '../../extent.js'; import _ol_layer_VectorRenderType_ from '../../layer/VectorRenderType.js'; @@ -125,7 +125,7 @@ CanvasImageLayerRenderer.prototype.prepareFrame = function(frameState, layerStat renderedExtent = getIntersection(renderedExtent, layerState.extent); } - if (!hints[_ol_ViewHint_.ANIMATING] && !hints[_ol_ViewHint_.INTERACTING] && + if (!hints[ViewHint.ANIMATING] && !hints[ViewHint.INTERACTING] && !isEmpty(renderedExtent)) { var projection = viewState.projection; if (!ENABLE_RASTER_REPROJECTION) { diff --git a/src/ol/renderer/canvas/TileLayer.js b/src/ol/renderer/canvas/TileLayer.js index dbd008ba9a..df933c1e10 100644 --- a/src/ol/renderer/canvas/TileLayer.js +++ b/src/ol/renderer/canvas/TileLayer.js @@ -5,7 +5,7 @@ import {getUid, inherits} from '../../index.js'; import LayerType from '../../LayerType.js'; import TileRange from '../../TileRange.js'; import TileState from '../../TileState.js'; -import _ol_ViewHint_ from '../../ViewHint.js'; +import ViewHint from '../../ViewHint.js'; import {createCanvasContext2D} from '../../dom.js'; import {containsExtent, createEmpty, equals, getIntersection, isEmpty} from '../../extent.js'; import RendererType from '../Type.js'; @@ -209,7 +209,7 @@ CanvasTileLayerRenderer.prototype.prepareFrame = function(frameState, layerState var renderedResolution = tileResolution * pixelRatio / tilePixelRatio * oversampling; var hints = frameState.viewHints; - var animatingOrInteracting = hints[_ol_ViewHint_.ANIMATING] || hints[_ol_ViewHint_.INTERACTING]; + var animatingOrInteracting = hints[ViewHint.ANIMATING] || hints[ViewHint.INTERACTING]; if (!(this.renderedResolution && Date.now() - frameState.time > 16 && animatingOrInteracting) && ( newTiles || !(this.renderedExtent_ && containsExtent(this.renderedExtent_, extent)) || diff --git a/src/ol/renderer/canvas/VectorLayer.js b/src/ol/renderer/canvas/VectorLayer.js index f178bfe9df..4f52ddc0bf 100644 --- a/src/ol/renderer/canvas/VectorLayer.js +++ b/src/ol/renderer/canvas/VectorLayer.js @@ -3,7 +3,7 @@ */ import {getUid, inherits} from '../../index.js'; import LayerType from '../../LayerType.js'; -import _ol_ViewHint_ from '../../ViewHint.js'; +import ViewHint from '../../ViewHint.js'; import {createCanvasContext2D} from '../../dom.js'; import _ol_events_ from '../../events.js'; import EventType from '../../events/EventType.js'; @@ -301,8 +301,8 @@ CanvasVectorLayerRenderer.prototype.prepareFrame = function(frameState, layerSta var vectorLayer = /** @type {ol.layer.Vector} */ (this.getLayer()); var vectorSource = vectorLayer.getSource(); - var animating = frameState.viewHints[_ol_ViewHint_.ANIMATING]; - var interacting = frameState.viewHints[_ol_ViewHint_.INTERACTING]; + var animating = frameState.viewHints[ViewHint.ANIMATING]; + var interacting = frameState.viewHints[ViewHint.INTERACTING]; var updateWhileAnimating = vectorLayer.getUpdateWhileAnimating(); var updateWhileInteracting = vectorLayer.getUpdateWhileInteracting(); diff --git a/src/ol/renderer/webgl/ImageLayer.js b/src/ol/renderer/webgl/ImageLayer.js index d53f2750a8..701d92fd9d 100644 --- a/src/ol/renderer/webgl/ImageLayer.js +++ b/src/ol/renderer/webgl/ImageLayer.js @@ -4,7 +4,7 @@ import {ENABLE_RASTER_REPROJECTION} from '../../reproj/common.js'; import {inherits, nullFunction} from '../../index.js'; import LayerType from '../../LayerType.js'; -import _ol_ViewHint_ from '../../ViewHint.js'; +import ViewHint from '../../ViewHint.js'; import {createCanvasContext2D} from '../../dom.js'; import {getIntersection, isEmpty} from '../../extent.js'; import {TRUE} from '../../functions.js'; @@ -139,7 +139,7 @@ WebGLImageLayerRenderer.prototype.prepareFrame = function(frameState, layerState if (layerState.extent !== undefined) { renderedExtent = getIntersection(renderedExtent, layerState.extent); } - if (!hints[_ol_ViewHint_.ANIMATING] && !hints[_ol_ViewHint_.INTERACTING] && + if (!hints[ViewHint.ANIMATING] && !hints[ViewHint.INTERACTING] && !isEmpty(renderedExtent)) { var projection = viewState.projection; if (!ENABLE_RASTER_REPROJECTION) { diff --git a/src/ol/renderer/webgl/VectorLayer.js b/src/ol/renderer/webgl/VectorLayer.js index e0b00949cb..a13c2eac19 100644 --- a/src/ol/renderer/webgl/VectorLayer.js +++ b/src/ol/renderer/webgl/VectorLayer.js @@ -3,7 +3,7 @@ */ import {getUid, inherits} from '../../index.js'; import LayerType from '../../LayerType.js'; -import _ol_ViewHint_ from '../../ViewHint.js'; +import ViewHint from '../../ViewHint.js'; import {buffer, containsExtent, createEmpty} from '../../extent.js'; import _ol_render_webgl_ReplayGroup_ from '../../render/webgl/ReplayGroup.js'; import RendererType from '../Type.js'; @@ -215,8 +215,8 @@ WebGLVectorLayerRenderer.prototype.prepareFrame = function(frameState, layerStat var vectorLayer = /** @type {ol.layer.Vector} */ (this.getLayer()); var vectorSource = vectorLayer.getSource(); - var animating = frameState.viewHints[_ol_ViewHint_.ANIMATING]; - var interacting = frameState.viewHints[_ol_ViewHint_.INTERACTING]; + var animating = frameState.viewHints[ViewHint.ANIMATING]; + var interacting = frameState.viewHints[ViewHint.INTERACTING]; var updateWhileAnimating = vectorLayer.getUpdateWhileAnimating(); var updateWhileInteracting = vectorLayer.getUpdateWhileInteracting(); diff --git a/test/spec/ol/view.test.js b/test/spec/ol/view.test.js index 19743e9815..a66cedf9f2 100644 --- a/test/spec/ol/view.test.js +++ b/test/spec/ol/view.test.js @@ -1,6 +1,6 @@ import Map from '../../../src/ol/Map.js'; import _ol_View_ from '../../../src/ol/View.js'; -import _ol_ViewHint_ from '../../../src/ol/ViewHint.js'; +import ViewHint from '../../../src/ol/ViewHint.js'; import * as _ol_extent_ from '../../../src/ol/extent.js'; import Circle from '../../../src/ol/geom/Circle.js'; import LineString from '../../../src/ol/geom/LineString.js'; @@ -311,7 +311,7 @@ describe('ol.View', function() { expect(view.getHints()).to.eql([0, 0]); expect(view.getInteracting()).to.eql(false); - view.setHint(_ol_ViewHint_.INTERACTING, 1); + view.setHint(ViewHint.INTERACTING, 1); expect(view.getHints()).to.eql([0, 1]); expect(view.getInteracting()).to.eql(true); }); @@ -327,7 +327,7 @@ describe('ol.View', function() { expect(view.getInteracting()).to.eql(true); done(); }); - view.setHint(_ol_ViewHint_.INTERACTING, 1); + view.setHint(ViewHint.INTERACTING, 1); }); }); @@ -680,7 +680,7 @@ describe('ol.View', function() { function decrement() { --count; if (count === 0) { - expect(view.getHints()[_ol_ViewHint_.ANIMATING]).to.be(0); + expect(view.getHints()[ViewHint.ANIMATING]).to.be(0); done(); } } @@ -688,19 +688,19 @@ describe('ol.View', function() { center: [1, 2], duration: 25 }, decrement); - expect(view.getHints()[_ol_ViewHint_.ANIMATING]).to.be(1); + expect(view.getHints()[ViewHint.ANIMATING]).to.be(1); view.animate({ zoom: 1, duration: 25 }, decrement); - expect(view.getHints()[_ol_ViewHint_.ANIMATING]).to.be(2); + expect(view.getHints()[ViewHint.ANIMATING]).to.be(2); view.animate({ rotation: Math.PI, duration: 25 }, decrement); - expect(view.getHints()[_ol_ViewHint_.ANIMATING]).to.be(3); + expect(view.getHints()[ViewHint.ANIMATING]).to.be(3); }); @@ -715,23 +715,23 @@ describe('ol.View', function() { center: [1, 2], duration: 25 }); - expect(view.getHints()[_ol_ViewHint_.ANIMATING]).to.be(1); + expect(view.getHints()[ViewHint.ANIMATING]).to.be(1); view.animate({ zoom: 1, duration: 25 }); - expect(view.getHints()[_ol_ViewHint_.ANIMATING]).to.be(2); + expect(view.getHints()[ViewHint.ANIMATING]).to.be(2); view.animate({ rotation: Math.PI, duration: 25 }); - expect(view.getHints()[_ol_ViewHint_.ANIMATING]).to.be(3); + expect(view.getHints()[ViewHint.ANIMATING]).to.be(3); // cancel animations view.setCenter([10, 20]); - expect(view.getHints()[_ol_ViewHint_.ANIMATING]).to.be(0); + expect(view.getHints()[ViewHint.ANIMATING]).to.be(0); });