Rename freeze/thaw to freezeRendering/unfreezeRendering
This commit is contained in:
+28
-29
@@ -1,4 +1,3 @@
|
|||||||
// FIXME rename freeze/thaw to freezeRendering/unfreezeRendering
|
|
||||||
// FIXME add change resolution by zoom step function
|
// FIXME add change resolution by zoom step function
|
||||||
// FIXME recheck layer/map projection compatability when projection changes
|
// FIXME recheck layer/map projection compatability when projection changes
|
||||||
// FIXME layer renderers should skip when they can't reproject
|
// FIXME layer renderers should skip when they can't reproject
|
||||||
@@ -135,7 +134,7 @@ ol.Map = function(target, opt_values, opt_viewportSizeMonitor) {
|
|||||||
* @private
|
* @private
|
||||||
* @type {number}
|
* @type {number}
|
||||||
*/
|
*/
|
||||||
this.freezeCount_ = 0;
|
this.freezeRenderingCount_ = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
@@ -219,13 +218,6 @@ ol.Map.prototype.animate_ = function() {
|
|||||||
ol.Map.prototype.createLayerRenderer = goog.abstractMethod;
|
ol.Map.prototype.createLayerRenderer = goog.abstractMethod;
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
ol.Map.prototype.freeze = function() {
|
|
||||||
++this.freezeCount_;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
@@ -241,7 +233,7 @@ ol.Map.prototype.disposeInternal = function() {
|
|||||||
* @param {ol.Extent} extent Extent.
|
* @param {ol.Extent} extent Extent.
|
||||||
*/
|
*/
|
||||||
ol.Map.prototype.fitExtent = function(extent) {
|
ol.Map.prototype.fitExtent = function(extent) {
|
||||||
this.whileFrozen(function() {
|
this.withFrozenRendering(function() {
|
||||||
this.setCenter(extent.getCenter());
|
this.setCenter(extent.getCenter());
|
||||||
this.setResolution(this.getResolutionForExtent(extent));
|
this.setResolution(this.getResolutionForExtent(extent));
|
||||||
}, this);
|
}, this);
|
||||||
@@ -272,6 +264,13 @@ ol.Map.prototype.forEachVisibleLayer = function(f, opt_obj) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
ol.Map.prototype.freezeRendering = function() {
|
||||||
|
++this.freezeRenderingCount_;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return {ol.Color|undefined} Background color.
|
* @return {ol.Color|undefined} Background color.
|
||||||
*/
|
*/
|
||||||
@@ -640,7 +639,7 @@ ol.Map.prototype.recalculateTransforms_ = function() {
|
|||||||
*/
|
*/
|
||||||
ol.Map.prototype.render = function() {
|
ol.Map.prototype.render = function() {
|
||||||
if (!this.animating_) {
|
if (!this.animating_) {
|
||||||
if (this.freezeCount_ === 0) {
|
if (this.freezeRenderingCount_ === 0) {
|
||||||
if (this.renderInternal()) {
|
if (this.renderInternal()) {
|
||||||
this.animate_();
|
this.animate_();
|
||||||
}
|
}
|
||||||
@@ -776,25 +775,10 @@ ol.Map.prototype.setUserProjection = function(userProjection) {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {function(this: T)} f Function.
|
|
||||||
* @param {T=} opt_obj Object.
|
|
||||||
* @template T
|
|
||||||
*/
|
*/
|
||||||
ol.Map.prototype.whileFrozen = function(f, opt_obj) {
|
ol.Map.prototype.unfreezeRendering = function() {
|
||||||
this.freeze();
|
goog.asserts.assert(this.freezeRenderingCount_ > 0);
|
||||||
try {
|
if (--this.freezeRenderingCount_ === 0) {
|
||||||
f.call(opt_obj);
|
|
||||||
} finally {
|
|
||||||
this.thaw();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
ol.Map.prototype.thaw = function() {
|
|
||||||
goog.asserts.assert(this.freezeCount_ > 0);
|
|
||||||
if (--this.freezeCount_ === 0) {
|
|
||||||
if (!this.animating_ && this.dirty_) {
|
if (!this.animating_ && this.dirty_) {
|
||||||
if (this.renderInternal()) {
|
if (this.renderInternal()) {
|
||||||
this.animate_();
|
this.animate_();
|
||||||
@@ -804,6 +788,21 @@ ol.Map.prototype.thaw = function() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {function(this: T)} f Function.
|
||||||
|
* @param {T=} opt_obj Object.
|
||||||
|
* @template T
|
||||||
|
*/
|
||||||
|
ol.Map.prototype.withFrozenRendering = function(f, opt_obj) {
|
||||||
|
this.freezeRendering();
|
||||||
|
try {
|
||||||
|
f.call(opt_obj);
|
||||||
|
} finally {
|
||||||
|
this.unfreezeRendering();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @constructor
|
* @constructor
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ ol.control.DblClickZoom.prototype.handleMapBrowserEvent =
|
|||||||
function(mapBrowserEvent) {
|
function(mapBrowserEvent) {
|
||||||
if (mapBrowserEvent.type == goog.events.EventType.DBLCLICK) {
|
if (mapBrowserEvent.type == goog.events.EventType.DBLCLICK) {
|
||||||
var map = mapBrowserEvent.map;
|
var map = mapBrowserEvent.map;
|
||||||
map.whileFrozen(function() {
|
map.withFrozenRendering(function() {
|
||||||
// FIXME compute correct center for zoom
|
// FIXME compute correct center for zoom
|
||||||
map.setCenter(mapBrowserEvent.getCoordinate());
|
map.setCenter(mapBrowserEvent.getCoordinate());
|
||||||
var browserEvent = mapBrowserEvent.browserEvent;
|
var browserEvent = mapBrowserEvent.browserEvent;
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ ol.control.MouseWheelZoom.prototype.handleMapBrowserEvent =
|
|||||||
mapBrowserEvent.browserEvent;
|
mapBrowserEvent.browserEvent;
|
||||||
goog.asserts.assert(mouseWheelEvent instanceof goog.events.MouseWheelEvent);
|
goog.asserts.assert(mouseWheelEvent instanceof goog.events.MouseWheelEvent);
|
||||||
if (mouseWheelEvent.deltaY !== 0) {
|
if (mouseWheelEvent.deltaY !== 0) {
|
||||||
map.whileFrozen(function() {
|
map.withFrozenRendering(function() {
|
||||||
// FIXME compute correct center for zoom
|
// FIXME compute correct center for zoom
|
||||||
map.setCenter(mapBrowserEvent.getCoordinate());
|
map.setCenter(mapBrowserEvent.getCoordinate());
|
||||||
var scale = mouseWheelEvent.deltaY < 0 ? 0.5 : 2;
|
var scale = mouseWheelEvent.deltaY < 0 ? 0.5 : 2;
|
||||||
|
|||||||
Reference in New Issue
Block a user