Only resize canvas when renderering
This commit is contained in:
@@ -153,6 +153,12 @@ ol.renderer.webgl.Map = function(container, map) {
|
|||||||
this.canvas_.width = container.clientWidth;
|
this.canvas_.width = container.clientWidth;
|
||||||
goog.dom.appendChild(container, this.canvas_);
|
goog.dom.appendChild(container, this.canvas_);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @private
|
||||||
|
* @type {ol.Size}
|
||||||
|
*/
|
||||||
|
this.canvasSize_ = new ol.Size(container.clientHeight, container.clientWidth);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
* @type {WebGLRenderingContext}
|
* @type {WebGLRenderingContext}
|
||||||
@@ -456,17 +462,7 @@ ol.renderer.webgl.Map.prototype.handleRotationChanged = function() {
|
|||||||
*/
|
*/
|
||||||
ol.renderer.webgl.Map.prototype.handleSizeChanged = function() {
|
ol.renderer.webgl.Map.prototype.handleSizeChanged = function() {
|
||||||
goog.base(this, 'handleSizeChanged');
|
goog.base(this, 'handleSizeChanged');
|
||||||
var size = this.getMap().getSize();
|
this.getMap().render();
|
||||||
if (!goog.isDef(size)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
this.canvas_.width = size.width;
|
|
||||||
this.canvas_.height = size.height;
|
|
||||||
var gl = this.gl_;
|
|
||||||
if (!goog.isNull(gl)) {
|
|
||||||
gl.viewport(0, 0, size.width, size.height);
|
|
||||||
this.getMap().render();
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -558,7 +554,12 @@ ol.renderer.webgl.Map.prototype.render = function() {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
var size = this.getMap().getSize();
|
var size = /** @type {ol.Size} */ this.getMap().getSize();
|
||||||
|
if (!this.canvasSize_.equals(size)) {
|
||||||
|
this.canvas_.width = size.width;
|
||||||
|
this.canvas_.height = size.height;
|
||||||
|
this.canvasSize_ = size;
|
||||||
|
}
|
||||||
|
|
||||||
var animate = goog.base(this, 'render');
|
var animate = goog.base(this, 'render');
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user