introduce new property on the Map called autoUpdateSize which lets applications take control of window resizing / device orientation changes if they want to
This commit is contained in:
@@ -376,6 +376,13 @@ OpenLayers.Map = OpenLayers.Class({
|
||||
* Default is to fall through.
|
||||
*/
|
||||
fallThrough: true,
|
||||
|
||||
/**
|
||||
* APIProperty: autoUpdateSize
|
||||
* {Boolean} Should OpenLayers automatically update the size of the map
|
||||
* when the resize event is fired. Default is true.
|
||||
*/
|
||||
autoUpdateSize: true,
|
||||
|
||||
/**
|
||||
* Property: panTween
|
||||
@@ -578,20 +585,22 @@ OpenLayers.Map = OpenLayers.Class({
|
||||
if(this.eventListeners instanceof Object) {
|
||||
this.events.on(this.eventListeners);
|
||||
}
|
||||
|
||||
// Because Mozilla does not support the "resize" event for elements
|
||||
// other than "window", we need to put a hack here.
|
||||
if (parseFloat(navigator.appVersion.split("MSIE")[1]) < 9) {
|
||||
// If IE < 9, register the resize on the div
|
||||
this.events.register("resize", this, this.updateSize);
|
||||
} else {
|
||||
// Else updateSize on catching the window's resize
|
||||
// Note that this is ok, as updateSize() does nothing if the
|
||||
// map's size has not actually changed.
|
||||
this.updateSizeDestroy = OpenLayers.Function.bind(this.updateSize,
|
||||
this);
|
||||
OpenLayers.Event.observe(window, 'resize',
|
||||
this.updateSizeDestroy);
|
||||
|
||||
if (this.autoUpdateSize === true) {
|
||||
// Because Mozilla does not support the "resize" event for elements
|
||||
// other than "window", we need to put a hack here.
|
||||
if (parseFloat(navigator.appVersion.split("MSIE")[1]) < 9) {
|
||||
// If IE < 9, register the resize on the div
|
||||
this.events.register("resize", this, this.updateSize);
|
||||
} else {
|
||||
// Else updateSize on catching the window's resize
|
||||
// Note that this is ok, as updateSize() does nothing if the
|
||||
// map's size has not actually changed.
|
||||
this.updateSizeDestroy = OpenLayers.Function.bind(this.updateSize,
|
||||
this);
|
||||
OpenLayers.Event.observe(window, 'resize',
|
||||
this.updateSizeDestroy);
|
||||
}
|
||||
}
|
||||
|
||||
// only append link stylesheet if the theme property is set
|
||||
@@ -744,12 +753,14 @@ OpenLayers.Map = OpenLayers.Class({
|
||||
OpenLayers.Event.stopObserving(window, 'unload', this.unloadDestroy);
|
||||
this.unloadDestroy = null;
|
||||
|
||||
if (this.updateSizeDestroy) {
|
||||
OpenLayers.Event.stopObserving(window, 'resize',
|
||||
this.updateSizeDestroy);
|
||||
} else {
|
||||
this.events.unregister("resize", this, this.updateSize);
|
||||
}
|
||||
if (this.autoUpdateSize === true) {
|
||||
if (this.updateSizeDestroy) {
|
||||
OpenLayers.Event.stopObserving(window, 'resize',
|
||||
this.updateSizeDestroy);
|
||||
} else {
|
||||
this.events.unregister("resize", this, this.updateSize);
|
||||
}
|
||||
}
|
||||
|
||||
this.paddingForPopups = null;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user