Remove hint enum from view constructor

This commit is contained in:
Tim Schaub
2016-12-27 09:40:53 -07:00
parent 62a0dd5b5b
commit 3852c0da83
18 changed files with 75 additions and 72 deletions
+9 -9
View File
@@ -1,7 +1,7 @@
goog.provide('ol.animation'); goog.provide('ol.animation');
goog.require('ol'); goog.require('ol');
goog.require('ol.View'); goog.require('ol.ViewHint');
goog.require('ol.coordinate'); goog.require('ol.coordinate');
goog.require('ol.easing'); goog.require('ol.easing');
@@ -30,14 +30,14 @@ ol.animation.bounce = function(options) {
function(map, frameState) { function(map, frameState) {
if (frameState.time < start) { if (frameState.time < start) {
frameState.animate = true; frameState.animate = true;
frameState.viewHints[ol.View.Hint.ANIMATING] += 1; frameState.viewHints[ol.ViewHint.ANIMATING] += 1;
return true; return true;
} else if (frameState.time < start + duration) { } else if (frameState.time < start + duration) {
var delta = easing((frameState.time - start) / duration); var delta = easing((frameState.time - start) / duration);
var deltaResolution = resolution - frameState.viewState.resolution; var deltaResolution = resolution - frameState.viewState.resolution;
frameState.animate = true; frameState.animate = true;
frameState.viewState.resolution += delta * deltaResolution; frameState.viewState.resolution += delta * deltaResolution;
frameState.viewHints[ol.View.Hint.ANIMATING] += 1; frameState.viewHints[ol.ViewHint.ANIMATING] += 1;
return true; return true;
} else { } else {
return false; return false;
@@ -71,7 +71,7 @@ ol.animation.pan = function(options) {
function(map, frameState) { function(map, frameState) {
if (frameState.time < start) { if (frameState.time < start) {
frameState.animate = true; frameState.animate = true;
frameState.viewHints[ol.View.Hint.ANIMATING] += 1; frameState.viewHints[ol.ViewHint.ANIMATING] += 1;
return true; return true;
} else if (frameState.time < start + duration) { } else if (frameState.time < start + duration) {
var delta = 1 - easing((frameState.time - start) / duration); var delta = 1 - easing((frameState.time - start) / duration);
@@ -80,7 +80,7 @@ ol.animation.pan = function(options) {
frameState.animate = true; frameState.animate = true;
frameState.viewState.center[0] += delta * deltaX; frameState.viewState.center[0] += delta * deltaX;
frameState.viewState.center[1] += delta * deltaY; frameState.viewState.center[1] += delta * deltaY;
frameState.viewHints[ol.View.Hint.ANIMATING] += 1; frameState.viewHints[ol.ViewHint.ANIMATING] += 1;
return true; return true;
} else { } else {
return false; return false;
@@ -115,7 +115,7 @@ ol.animation.rotate = function(options) {
function(map, frameState) { function(map, frameState) {
if (frameState.time < start) { if (frameState.time < start) {
frameState.animate = true; frameState.animate = true;
frameState.viewHints[ol.View.Hint.ANIMATING] += 1; frameState.viewHints[ol.ViewHint.ANIMATING] += 1;
return true; return true;
} else if (frameState.time < start + duration) { } else if (frameState.time < start + duration) {
var delta = 1 - easing((frameState.time - start) / duration); var delta = 1 - easing((frameState.time - start) / duration);
@@ -129,7 +129,7 @@ ol.animation.rotate = function(options) {
ol.coordinate.rotate(center, deltaRotation); ol.coordinate.rotate(center, deltaRotation);
ol.coordinate.add(center, anchor); ol.coordinate.add(center, anchor);
} }
frameState.viewHints[ol.View.Hint.ANIMATING] += 1; frameState.viewHints[ol.ViewHint.ANIMATING] += 1;
return true; return true;
} else { } else {
return false; return false;
@@ -161,7 +161,7 @@ ol.animation.zoom = function(options) {
function(map, frameState) { function(map, frameState) {
if (frameState.time < start) { if (frameState.time < start) {
frameState.animate = true; frameState.animate = true;
frameState.viewHints[ol.View.Hint.ANIMATING] += 1; frameState.viewHints[ol.ViewHint.ANIMATING] += 1;
return true; return true;
} else if (frameState.time < start + duration) { } else if (frameState.time < start + duration) {
var delta = 1 - easing((frameState.time - start) / duration); var delta = 1 - easing((frameState.time - start) / duration);
@@ -169,7 +169,7 @@ ol.animation.zoom = function(options) {
sourceResolution - frameState.viewState.resolution; sourceResolution - frameState.viewState.resolution;
frameState.animate = true; frameState.animate = true;
frameState.viewState.resolution += delta * deltaResolution; frameState.viewState.resolution += delta * deltaResolution;
frameState.viewHints[ol.View.Hint.ANIMATING] += 1; frameState.viewHints[ol.ViewHint.ANIMATING] += 1;
return true; return true;
} else { } else {
return false; return false;
+3 -3
View File
@@ -3,7 +3,7 @@
goog.provide('ol.control.ZoomSlider'); goog.provide('ol.control.ZoomSlider');
goog.require('ol'); goog.require('ol');
goog.require('ol.View'); goog.require('ol.ViewHint');
goog.require('ol.control.Control'); goog.require('ol.control.Control');
goog.require('ol.css'); goog.require('ol.css');
goog.require('ol.easing'); goog.require('ol.easing');
@@ -256,7 +256,7 @@ ol.control.ZoomSlider.prototype.handleContainerClick_ = function(event) {
ol.control.ZoomSlider.prototype.handleDraggerStart_ = function(event) { ol.control.ZoomSlider.prototype.handleDraggerStart_ = function(event) {
if (!this.dragging_ && if (!this.dragging_ &&
event.originalEvent.target === this.element.firstElementChild) { event.originalEvent.target === this.element.firstElementChild) {
this.getMap().getView().setHint(ol.View.Hint.INTERACTING, 1); this.getMap().getView().setHint(ol.ViewHint.INTERACTING, 1);
this.previousX_ = event.clientX; this.previousX_ = event.clientX;
this.previousY_ = event.clientY; this.previousY_ = event.clientY;
this.dragging_ = true; this.dragging_ = true;
@@ -306,7 +306,7 @@ ol.control.ZoomSlider.prototype.handleDraggerDrag_ = function(event) {
ol.control.ZoomSlider.prototype.handleDraggerEnd_ = function(event) { ol.control.ZoomSlider.prototype.handleDraggerEnd_ = function(event) {
if (this.dragging_) { if (this.dragging_) {
var view = this.getMap().getView(); var view = this.getMap().getView();
view.setHint(ol.View.Hint.INTERACTING, -1); view.setHint(ol.ViewHint.INTERACTING, -1);
view.animate({ view.animate({
resolution: view.constrainResolution(this.currentResolution_), resolution: view.constrainResolution(this.currentResolution_),
+3 -3
View File
@@ -1,7 +1,7 @@
goog.provide('ol.interaction.DragPan'); goog.provide('ol.interaction.DragPan');
goog.require('ol'); goog.require('ol');
goog.require('ol.View'); goog.require('ol.ViewHint');
goog.require('ol.coordinate'); goog.require('ol.coordinate');
goog.require('ol.easing'); goog.require('ol.easing');
goog.require('ol.events.condition'); goog.require('ol.events.condition');
@@ -111,7 +111,7 @@ ol.interaction.DragPan.handleUpEvent_ = function(mapBrowserEvent) {
easing: ol.easing.easeOut easing: ol.easing.easeOut
}); });
} }
view.setHint(ol.View.Hint.INTERACTING, -1); view.setHint(ol.ViewHint.INTERACTING, -1);
return false; return false;
} else { } else {
this.lastCentroid = null; this.lastCentroid = null;
@@ -132,7 +132,7 @@ ol.interaction.DragPan.handleDownEvent_ = function(mapBrowserEvent) {
var view = map.getView(); var view = map.getView();
this.lastCentroid = null; this.lastCentroid = null;
if (!this.handlingDownUpSequence) { if (!this.handlingDownUpSequence) {
view.setHint(ol.View.Hint.INTERACTING, 1); view.setHint(ol.ViewHint.INTERACTING, 1);
} }
// stop any current animation // stop any current animation
view.setCenter(mapBrowserEvent.frameState.viewState.center); view.setCenter(mapBrowserEvent.frameState.viewState.center);
+3 -3
View File
@@ -1,7 +1,7 @@
goog.provide('ol.interaction.DragRotate'); goog.provide('ol.interaction.DragRotate');
goog.require('ol'); goog.require('ol');
goog.require('ol.View'); goog.require('ol.ViewHint');
goog.require('ol.events.condition'); goog.require('ol.events.condition');
goog.require('ol.functions'); goog.require('ol.functions');
goog.require('ol.interaction.Interaction'); goog.require('ol.interaction.Interaction');
@@ -92,7 +92,7 @@ ol.interaction.DragRotate.handleUpEvent_ = function(mapBrowserEvent) {
var map = mapBrowserEvent.map; var map = mapBrowserEvent.map;
var view = map.getView(); var view = map.getView();
view.setHint(ol.View.Hint.INTERACTING, -1); view.setHint(ol.ViewHint.INTERACTING, -1);
var rotation = view.getRotation(); var rotation = view.getRotation();
ol.interaction.Interaction.rotate(map, view, rotation, ol.interaction.Interaction.rotate(map, view, rotation,
undefined, this.duration_); undefined, this.duration_);
@@ -114,7 +114,7 @@ ol.interaction.DragRotate.handleDownEvent_ = function(mapBrowserEvent) {
if (ol.events.condition.mouseActionButton(mapBrowserEvent) && if (ol.events.condition.mouseActionButton(mapBrowserEvent) &&
this.condition_(mapBrowserEvent)) { this.condition_(mapBrowserEvent)) {
var map = mapBrowserEvent.map; var map = mapBrowserEvent.map;
map.getView().setHint(ol.View.Hint.INTERACTING, 1); map.getView().setHint(ol.ViewHint.INTERACTING, 1);
this.lastAngle_ = undefined; this.lastAngle_ = undefined;
return true; return true;
} else { } else {
+3 -3
View File
@@ -1,7 +1,7 @@
goog.provide('ol.interaction.DragRotateAndZoom'); goog.provide('ol.interaction.DragRotateAndZoom');
goog.require('ol'); goog.require('ol');
goog.require('ol.View'); goog.require('ol.ViewHint');
goog.require('ol.events.condition'); goog.require('ol.events.condition');
goog.require('ol.interaction.Interaction'); goog.require('ol.interaction.Interaction');
goog.require('ol.interaction.Pointer'); goog.require('ol.interaction.Pointer');
@@ -115,7 +115,7 @@ ol.interaction.DragRotateAndZoom.handleUpEvent_ = function(mapBrowserEvent) {
var map = mapBrowserEvent.map; var map = mapBrowserEvent.map;
var view = map.getView(); var view = map.getView();
view.setHint(ol.View.Hint.INTERACTING, -1); view.setHint(ol.ViewHint.INTERACTING, -1);
var direction = this.lastScaleDelta_ - 1; var direction = this.lastScaleDelta_ - 1;
ol.interaction.Interaction.rotate(map, view, view.getRotation()); ol.interaction.Interaction.rotate(map, view, view.getRotation());
ol.interaction.Interaction.zoom(map, view, view.getResolution(), ol.interaction.Interaction.zoom(map, view, view.getResolution(),
@@ -137,7 +137,7 @@ ol.interaction.DragRotateAndZoom.handleDownEvent_ = function(mapBrowserEvent) {
} }
if (this.condition_(mapBrowserEvent)) { if (this.condition_(mapBrowserEvent)) {
mapBrowserEvent.map.getView().setHint(ol.View.Hint.INTERACTING, 1); mapBrowserEvent.map.getView().setHint(ol.ViewHint.INTERACTING, 1);
this.lastAngle_ = undefined; this.lastAngle_ = undefined;
this.lastMagnitude_ = undefined; this.lastMagnitude_ = undefined;
return true; return true;
+2 -2
View File
@@ -5,7 +5,7 @@ goog.require('ol.Collection');
goog.require('ol.Feature'); goog.require('ol.Feature');
goog.require('ol.MapBrowserEvent'); goog.require('ol.MapBrowserEvent');
goog.require('ol.MapBrowserPointerEvent'); goog.require('ol.MapBrowserPointerEvent');
goog.require('ol.View'); goog.require('ol.ViewHint');
goog.require('ol.array'); goog.require('ol.array');
goog.require('ol.coordinate'); goog.require('ol.coordinate');
goog.require('ol.events'); goog.require('ol.events');
@@ -655,7 +655,7 @@ ol.interaction.Modify.handleEvent = function(mapBrowserEvent) {
this.lastPointerEvent_ = mapBrowserEvent; this.lastPointerEvent_ = mapBrowserEvent;
var handled; var handled;
if (!mapBrowserEvent.map.getView().getHints()[ol.View.Hint.INTERACTING] && if (!mapBrowserEvent.map.getView().getHints()[ol.ViewHint.INTERACTING] &&
mapBrowserEvent.type == ol.MapBrowserEvent.EventType.POINTERMOVE && mapBrowserEvent.type == ol.MapBrowserEvent.EventType.POINTERMOVE &&
!this.handlingDownUpSequence) { !this.handlingDownUpSequence) {
this.handlePointerMove_(mapBrowserEvent); this.handlePointerMove_(mapBrowserEvent);
+3 -3
View File
@@ -1,7 +1,7 @@
goog.provide('ol.interaction.MouseWheelZoom'); goog.provide('ol.interaction.MouseWheelZoom');
goog.require('ol'); goog.require('ol');
goog.require('ol.View'); goog.require('ol.ViewHint');
goog.require('ol.easing'); goog.require('ol.easing');
goog.require('ol.events.EventType'); goog.require('ol.events.EventType');
goog.require('ol.has'); goog.require('ol.has');
@@ -167,7 +167,7 @@ ol.interaction.MouseWheelZoom.handleEvent = function(mapBrowserEvent) {
if (this.trackpadTimeoutId_) { if (this.trackpadTimeoutId_) {
clearTimeout(this.trackpadTimeoutId_); clearTimeout(this.trackpadTimeoutId_);
} else { } else {
view.setHint(ol.View.Hint.INTERACTING, 1); view.setHint(ol.ViewHint.INTERACTING, 1);
} }
this.trackpadTimeoutId_ = setTimeout(this.decrementInteractingHint_.bind(this), this.trackpadEventGap_); this.trackpadTimeoutId_ = setTimeout(this.decrementInteractingHint_.bind(this), this.trackpadEventGap_);
var resolution = view.getResolution() * Math.pow(2, delta / this.trackpadDeltaPerZoom_); var resolution = view.getResolution() * Math.pow(2, delta / this.trackpadDeltaPerZoom_);
@@ -222,7 +222,7 @@ ol.interaction.MouseWheelZoom.handleEvent = function(mapBrowserEvent) {
ol.interaction.MouseWheelZoom.prototype.decrementInteractingHint_ = function() { ol.interaction.MouseWheelZoom.prototype.decrementInteractingHint_ = function() {
this.trackpadTimeoutId_ = undefined; this.trackpadTimeoutId_ = undefined;
var view = this.getMap().getView(); var view = this.getMap().getView();
view.setHint(ol.View.Hint.INTERACTING, -1); view.setHint(ol.ViewHint.INTERACTING, -1);
}; };
+3 -3
View File
@@ -1,7 +1,7 @@
goog.provide('ol.interaction.PinchRotate'); goog.provide('ol.interaction.PinchRotate');
goog.require('ol'); goog.require('ol');
goog.require('ol.View'); goog.require('ol.ViewHint');
goog.require('ol.functions'); goog.require('ol.functions');
goog.require('ol.interaction.Interaction'); goog.require('ol.interaction.Interaction');
goog.require('ol.interaction.Pointer'); goog.require('ol.interaction.Pointer');
@@ -128,7 +128,7 @@ ol.interaction.PinchRotate.handleUpEvent_ = function(mapBrowserEvent) {
if (this.targetPointers.length < 2) { if (this.targetPointers.length < 2) {
var map = mapBrowserEvent.map; var map = mapBrowserEvent.map;
var view = map.getView(); var view = map.getView();
view.setHint(ol.View.Hint.INTERACTING, -1); view.setHint(ol.ViewHint.INTERACTING, -1);
if (this.rotating_) { if (this.rotating_) {
var rotation = view.getRotation(); var rotation = view.getRotation();
ol.interaction.Interaction.rotate( ol.interaction.Interaction.rotate(
@@ -155,7 +155,7 @@ ol.interaction.PinchRotate.handleDownEvent_ = function(mapBrowserEvent) {
this.rotating_ = false; this.rotating_ = false;
this.rotationDelta_ = 0.0; this.rotationDelta_ = 0.0;
if (!this.handlingDownUpSequence) { if (!this.handlingDownUpSequence) {
map.getView().setHint(ol.View.Hint.INTERACTING, 1); map.getView().setHint(ol.ViewHint.INTERACTING, 1);
} }
return true; return true;
} else { } else {
+3 -3
View File
@@ -1,7 +1,7 @@
goog.provide('ol.interaction.PinchZoom'); goog.provide('ol.interaction.PinchZoom');
goog.require('ol'); goog.require('ol');
goog.require('ol.View'); goog.require('ol.ViewHint');
goog.require('ol.functions'); goog.require('ol.functions');
goog.require('ol.interaction.Interaction'); goog.require('ol.interaction.Interaction');
goog.require('ol.interaction.Pointer'); goog.require('ol.interaction.Pointer');
@@ -116,7 +116,7 @@ ol.interaction.PinchZoom.handleUpEvent_ = function(mapBrowserEvent) {
if (this.targetPointers.length < 2) { if (this.targetPointers.length < 2) {
var map = mapBrowserEvent.map; var map = mapBrowserEvent.map;
var view = map.getView(); var view = map.getView();
view.setHint(ol.View.Hint.INTERACTING, -1); view.setHint(ol.ViewHint.INTERACTING, -1);
if (this.constrainResolution_) { if (this.constrainResolution_) {
var resolution = view.getResolution(); var resolution = view.getResolution();
// Zoom to final resolution, with an animation, and provide a // Zoom to final resolution, with an animation, and provide a
@@ -146,7 +146,7 @@ ol.interaction.PinchZoom.handleDownEvent_ = function(mapBrowserEvent) {
this.lastDistance_ = undefined; this.lastDistance_ = undefined;
this.lastScaleDelta_ = 1; this.lastScaleDelta_ = 1;
if (!this.handlingDownUpSequence) { if (!this.handlingDownUpSequence) {
map.getView().setHint(ol.View.Hint.INTERACTING, 1); map.getView().setHint(ol.ViewHint.INTERACTING, 1);
} }
return true; return true;
} else { } else {
+5 -4
View File
@@ -13,6 +13,7 @@ goog.require('ol.MapProperty');
goog.require('ol.Object'); goog.require('ol.Object');
goog.require('ol.TileQueue'); goog.require('ol.TileQueue');
goog.require('ol.View'); goog.require('ol.View');
goog.require('ol.ViewHint');
goog.require('ol.asserts'); goog.require('ol.asserts');
goog.require('ol.control'); goog.require('ol.control');
goog.require('ol.dom'); goog.require('ol.dom');
@@ -976,11 +977,11 @@ ol.Map.prototype.handlePostRender = function() {
var maxNewLoads = maxTotalLoading; var maxNewLoads = maxTotalLoading;
if (frameState) { if (frameState) {
var hints = frameState.viewHints; var hints = frameState.viewHints;
if (hints[ol.View.Hint.ANIMATING]) { if (hints[ol.ViewHint.ANIMATING]) {
maxTotalLoading = this.loadTilesWhileAnimating_ ? 8 : 0; maxTotalLoading = this.loadTilesWhileAnimating_ ? 8 : 0;
maxNewLoads = 2; maxNewLoads = 2;
} }
if (hints[ol.View.Hint.INTERACTING]) { if (hints[ol.ViewHint.INTERACTING]) {
maxTotalLoading = this.loadTilesWhileInteracting_ ? 8 : 0; maxTotalLoading = this.loadTilesWhileInteracting_ ? 8 : 0;
maxNewLoads = 2; maxNewLoads = 2;
} }
@@ -1279,8 +1280,8 @@ ol.Map.prototype.renderFrame_ = function(time) {
this.postRenderFunctions_, frameState.postRenderFunctions); this.postRenderFunctions_, frameState.postRenderFunctions);
var idle = this.preRenderFunctions_.length === 0 && var idle = this.preRenderFunctions_.length === 0 &&
!frameState.viewHints[ol.View.Hint.ANIMATING] && !frameState.viewHints[ol.ViewHint.ANIMATING] &&
!frameState.viewHints[ol.View.Hint.INTERACTING] && !frameState.viewHints[ol.ViewHint.INTERACTING] &&
!ol.extent.equals(frameState.extent, this.previousExtent_); !ol.extent.equals(frameState.extent, this.previousExtent_);
if (idle) { if (idle) {
+2 -2
View File
@@ -1,7 +1,7 @@
goog.provide('ol.renderer.canvas.ImageLayer'); goog.provide('ol.renderer.canvas.ImageLayer');
goog.require('ol'); goog.require('ol');
goog.require('ol.View'); goog.require('ol.ViewHint');
goog.require('ol.extent'); goog.require('ol.extent');
goog.require('ol.proj'); goog.require('ol.proj');
goog.require('ol.renderer.canvas.IntermediateCanvas'); goog.require('ol.renderer.canvas.IntermediateCanvas');
@@ -72,7 +72,7 @@ ol.renderer.canvas.ImageLayer.prototype.prepareFrame = function(frameState, laye
renderedExtent, layerState.extent); renderedExtent, layerState.extent);
} }
if (!hints[ol.View.Hint.ANIMATING] && !hints[ol.View.Hint.INTERACTING] && if (!hints[ol.ViewHint.ANIMATING] && !hints[ol.ViewHint.INTERACTING] &&
!ol.extent.isEmpty(renderedExtent)) { !ol.extent.isEmpty(renderedExtent)) {
var projection = viewState.projection; var projection = viewState.projection;
if (!ol.ENABLE_RASTER_REPROJECTION) { if (!ol.ENABLE_RASTER_REPROJECTION) {
+2 -2
View File
@@ -6,7 +6,7 @@ goog.require('ol');
goog.require('ol.transform'); goog.require('ol.transform');
goog.require('ol.TileRange'); goog.require('ol.TileRange');
goog.require('ol.Tile'); goog.require('ol.Tile');
goog.require('ol.View'); goog.require('ol.ViewHint');
goog.require('ol.array'); goog.require('ol.array');
goog.require('ol.dom'); goog.require('ol.dom');
goog.require('ol.extent'); goog.require('ol.extent');
@@ -171,7 +171,7 @@ ol.renderer.canvas.TileLayer.prototype.prepareFrame = function(frameState, layer
var hints = frameState.viewHints; var hints = frameState.viewHints;
if (!(this.renderedResolution && Date.now() - frameState.time > 16 && if (!(this.renderedResolution && Date.now() - frameState.time > 16 &&
(hints[ol.View.Hint.ANIMATING] || hints[ol.View.Hint.INTERACTING])) && (hints[ol.ViewHint.ANIMATING] || hints[ol.ViewHint.INTERACTING])) &&
(newTiles || !(this.renderedExtent_ && (newTiles || !(this.renderedExtent_ &&
ol.extent.equals(this.renderedExtent_, imageExtent)) || ol.extent.equals(this.renderedExtent_, imageExtent)) ||
this.renderedRevision != sourceRevision)) { this.renderedRevision != sourceRevision)) {
+3 -3
View File
@@ -1,7 +1,7 @@
goog.provide('ol.renderer.canvas.VectorLayer'); goog.provide('ol.renderer.canvas.VectorLayer');
goog.require('ol'); goog.require('ol');
goog.require('ol.View'); goog.require('ol.ViewHint');
goog.require('ol.dom'); goog.require('ol.dom');
goog.require('ol.extent'); goog.require('ol.extent');
goog.require('ol.render.EventType'); goog.require('ol.render.EventType');
@@ -225,8 +225,8 @@ ol.renderer.canvas.VectorLayer.prototype.prepareFrame = function(frameState, lay
frameState.attributions, vectorSource.getAttributions()); frameState.attributions, vectorSource.getAttributions());
this.updateLogos(frameState, vectorSource); this.updateLogos(frameState, vectorSource);
var animating = frameState.viewHints[ol.View.Hint.ANIMATING]; var animating = frameState.viewHints[ol.ViewHint.ANIMATING];
var interacting = frameState.viewHints[ol.View.Hint.INTERACTING]; var interacting = frameState.viewHints[ol.ViewHint.INTERACTING];
var updateWhileAnimating = vectorLayer.getUpdateWhileAnimating(); var updateWhileAnimating = vectorLayer.getUpdateWhileAnimating();
var updateWhileInteracting = vectorLayer.getUpdateWhileInteracting(); var updateWhileInteracting = vectorLayer.getUpdateWhileInteracting();
+2 -2
View File
@@ -1,7 +1,7 @@
goog.provide('ol.renderer.webgl.ImageLayer'); goog.provide('ol.renderer.webgl.ImageLayer');
goog.require('ol'); goog.require('ol');
goog.require('ol.View'); goog.require('ol.ViewHint');
goog.require('ol.dom'); goog.require('ol.dom');
goog.require('ol.extent'); goog.require('ol.extent');
goog.require('ol.functions'); goog.require('ol.functions');
@@ -112,7 +112,7 @@ ol.renderer.webgl.ImageLayer.prototype.prepareFrame = function(frameState, layer
renderedExtent = ol.extent.getIntersection( renderedExtent = ol.extent.getIntersection(
renderedExtent, layerState.extent); renderedExtent, layerState.extent);
} }
if (!hints[ol.View.Hint.ANIMATING] && !hints[ol.View.Hint.INTERACTING] && if (!hints[ol.ViewHint.ANIMATING] && !hints[ol.ViewHint.INTERACTING] &&
!ol.extent.isEmpty(renderedExtent)) { !ol.extent.isEmpty(renderedExtent)) {
var projection = viewState.projection; var projection = viewState.projection;
if (!ol.ENABLE_RASTER_REPROJECTION) { if (!ol.ENABLE_RASTER_REPROJECTION) {
+3 -3
View File
@@ -1,7 +1,7 @@
goog.provide('ol.renderer.webgl.VectorLayer'); goog.provide('ol.renderer.webgl.VectorLayer');
goog.require('ol'); goog.require('ol');
goog.require('ol.View'); goog.require('ol.ViewHint');
goog.require('ol.extent'); goog.require('ol.extent');
goog.require('ol.render.webgl.ReplayGroup'); goog.require('ol.render.webgl.ReplayGroup');
goog.require('ol.renderer.vector'); goog.require('ol.renderer.vector');
@@ -191,8 +191,8 @@ ol.renderer.webgl.VectorLayer.prototype.prepareFrame = function(frameState, laye
frameState.attributions, vectorSource.getAttributions()); frameState.attributions, vectorSource.getAttributions());
this.updateLogos(frameState, vectorSource); this.updateLogos(frameState, vectorSource);
var animating = frameState.viewHints[ol.View.Hint.ANIMATING]; var animating = frameState.viewHints[ol.ViewHint.ANIMATING];
var interacting = frameState.viewHints[ol.View.Hint.INTERACTING]; var interacting = frameState.viewHints[ol.ViewHint.INTERACTING];
var updateWhileAnimating = vectorLayer.getUpdateWhileAnimating(); var updateWhileAnimating = vectorLayer.getUpdateWhileAnimating();
var updateWhileInteracting = vectorLayer.getUpdateWhileInteracting(); var updateWhileInteracting = vectorLayer.getUpdateWhileInteracting();
+6 -14
View File
@@ -6,6 +6,7 @@ goog.require('ol.Constraints');
goog.require('ol.Object'); goog.require('ol.Object');
goog.require('ol.ResolutionConstraint'); goog.require('ol.ResolutionConstraint');
goog.require('ol.RotationConstraint'); goog.require('ol.RotationConstraint');
goog.require('ol.ViewHint');
goog.require('ol.ViewProperty'); goog.require('ol.ViewProperty');
goog.require('ol.array'); goog.require('ol.array');
goog.require('ol.asserts'); goog.require('ol.asserts');
@@ -254,7 +255,7 @@ ol.View.prototype.animate = function(var_args) {
series.push(animation); series.push(animation);
} }
this.animations_.push(series); this.animations_.push(series);
this.setHint(ol.View.Hint.ANIMATING, 1); this.setHint(ol.ViewHint.ANIMATING, 1);
this.updateAnimations_(); this.updateAnimations_();
}; };
@@ -264,7 +265,7 @@ ol.View.prototype.animate = function(var_args) {
* @return {boolean} The view is being animated. * @return {boolean} The view is being animated.
*/ */
ol.View.prototype.getAnimating = function() { ol.View.prototype.getAnimating = function() {
return this.getHints()[ol.View.Hint.ANIMATING] > 0; return this.getHints()[ol.ViewHint.ANIMATING] > 0;
}; };
@@ -272,7 +273,7 @@ ol.View.prototype.getAnimating = function() {
* Cancel any ongoing animations. * Cancel any ongoing animations.
*/ */
ol.View.prototype.cancelAnimations = function() { ol.View.prototype.cancelAnimations = function() {
this.setHint(ol.View.Hint.ANIMATING, -this.getHints()[ol.View.Hint.ANIMATING]); this.setHint(ol.ViewHint.ANIMATING, -this.getHints()[ol.ViewHint.ANIMATING]);
for (var i = 0, ii = this.animations_.length; i < ii; ++i) { for (var i = 0, ii = this.animations_.length; i < ii; ++i) {
var series = this.animations_[i]; var series = this.animations_[i];
if (series[0].callback) { if (series[0].callback) {
@@ -346,7 +347,7 @@ ol.View.prototype.updateAnimations_ = function() {
} }
if (seriesComplete) { if (seriesComplete) {
this.animations_[i] = null; this.animations_[i] = null;
this.setHint(ol.View.Hint.ANIMATING, -1); this.setHint(ol.ViewHint.ANIMATING, -1);
var callback = series[0].callback; var callback = series[0].callback;
if (callback) { if (callback) {
callback(true); callback(true);
@@ -839,7 +840,7 @@ ol.View.prototype.setCenter = function(center) {
/** /**
* @param {ol.View.Hint} hint Hint. * @param {ol.ViewHint} hint Hint.
* @param {number} delta Delta. * @param {number} delta Delta.
* @return {number} New value. * @return {number} New value.
*/ */
@@ -1015,12 +1016,3 @@ ol.View.createRotationConstraint_ = function(options) {
return ol.RotationConstraint.disable; return ol.RotationConstraint.disable;
} }
}; };
/**
* @enum {number}
*/
ol.View.Hint = {
ANIMATING: 0,
INTERACTING: 1
};
+9
View File
@@ -0,0 +1,9 @@
goog.provide('ol.ViewHint');
/**
* @enum {number}
*/
ol.ViewHint = {
ANIMATING: 0,
INTERACTING: 1
};
+11 -10
View File
@@ -2,6 +2,7 @@ goog.provide('ol.test.View');
goog.require('ol'); goog.require('ol');
goog.require('ol.View'); goog.require('ol.View');
goog.require('ol.ViewHint');
goog.require('ol.extent'); goog.require('ol.extent');
goog.require('ol.geom.LineString'); goog.require('ol.geom.LineString');
goog.require('ol.geom.Point'); goog.require('ol.geom.Point');
@@ -311,7 +312,7 @@ describe('ol.View', function() {
expect(view.getHints()).to.eql([0, 0]); expect(view.getHints()).to.eql([0, 0]);
view.setHint(ol.View.Hint.INTERACTING, 1); view.setHint(ol.ViewHint.INTERACTING, 1);
expect(view.getHints()).to.eql([0, 1]); expect(view.getHints()).to.eql([0, 1]);
}); });
@@ -325,7 +326,7 @@ describe('ol.View', function() {
expect(view.getHints()).to.eql([0, 1]); expect(view.getHints()).to.eql([0, 1]);
done(); done();
}); });
view.setHint(ol.View.Hint.INTERACTING, 1); view.setHint(ol.ViewHint.INTERACTING, 1);
}); });
}); });
@@ -477,7 +478,7 @@ describe('ol.View', function() {
function decrement() { function decrement() {
--count; --count;
if (count === 0) { if (count === 0) {
expect(view.getHints()[ol.View.Hint.ANIMATING]).to.be(0); expect(view.getHints()[ol.ViewHint.ANIMATING]).to.be(0);
done(); done();
} }
} }
@@ -485,19 +486,19 @@ describe('ol.View', function() {
center: [1, 2], center: [1, 2],
duration: 25 duration: 25
}, decrement); }, decrement);
expect(view.getHints()[ol.View.Hint.ANIMATING]).to.be(1); expect(view.getHints()[ol.ViewHint.ANIMATING]).to.be(1);
view.animate({ view.animate({
zoom: 1, zoom: 1,
duration: 25 duration: 25
}, decrement); }, decrement);
expect(view.getHints()[ol.View.Hint.ANIMATING]).to.be(2); expect(view.getHints()[ol.ViewHint.ANIMATING]).to.be(2);
view.animate({ view.animate({
rotate: Math.PI, rotate: Math.PI,
duration: 25 duration: 25
}, decrement); }, decrement);
expect(view.getHints()[ol.View.Hint.ANIMATING]).to.be(3); expect(view.getHints()[ol.ViewHint.ANIMATING]).to.be(3);
}); });
@@ -512,23 +513,23 @@ describe('ol.View', function() {
center: [1, 2], center: [1, 2],
duration: 25 duration: 25
}); });
expect(view.getHints()[ol.View.Hint.ANIMATING]).to.be(1); expect(view.getHints()[ol.ViewHint.ANIMATING]).to.be(1);
view.animate({ view.animate({
zoom: 1, zoom: 1,
duration: 25 duration: 25
}); });
expect(view.getHints()[ol.View.Hint.ANIMATING]).to.be(2); expect(view.getHints()[ol.ViewHint.ANIMATING]).to.be(2);
view.animate({ view.animate({
rotate: Math.PI, rotate: Math.PI,
duration: 25 duration: 25
}); });
expect(view.getHints()[ol.View.Hint.ANIMATING]).to.be(3); expect(view.getHints()[ol.ViewHint.ANIMATING]).to.be(3);
// cancel animations // cancel animations
view.setCenter([10, 20]); view.setCenter([10, 20]);
expect(view.getHints()[ol.View.Hint.ANIMATING]).to.be(0); expect(view.getHints()[ol.ViewHint.ANIMATING]).to.be(0);
}); });