Handle resizing

This commit is contained in:
Tom Payne
2012-07-14 19:23:08 +02:00
parent c7f418240f
commit f66016af2e
2 changed files with 64 additions and 39 deletions

View File

@@ -54,6 +54,8 @@ ol.webgl.Map = function(target, opt_values) {
this.setValues(opt_values);
}
this.handleViewportResize();
};
goog.inherits(ol.webgl.Map, ol.Map);
@@ -130,9 +132,19 @@ ol.webgl.Map.prototype.handleResolutionChanged = function() {
/**
* @inheritDoc
*/
ol.webgl.Map.prototype.handleTargetResize = function(event) {
goog.base(this, 'handleTargetResize', event);
this.updateSize_();
ol.webgl.Map.prototype.handleSizeChanged = function() {
goog.base(this, 'handleSizeChanged');
var size = this.getSize();
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.redraw_();
}
};
@@ -164,22 +176,6 @@ ol.webgl.Map.prototype.setGL = function(gl) {
this.forEachLayerRenderer(function(layerRenderer) {
layerRenderer.setGL(gl);
});
this.updateSize_();
this.redraw_();
}
};
/**
* @private
*/
ol.webgl.Map.prototype.updateSize_ = function() {
var size = this.getSize();
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.redraw_();
}
};