Merge pull request #637 from bartvde/resizecleanup
cleanup and always use window resize as suggested by @tonio (r=@tonio)
This commit is contained in:
+10
-21
@@ -587,20 +587,13 @@ OpenLayers.Map = OpenLayers.Class({
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (this.autoUpdateSize === true) {
|
if (this.autoUpdateSize === true) {
|
||||||
// Because Mozilla does not support the "resize" event for elements
|
// updateSize on catching the window's resize
|
||||||
// other than "window", we need to put a hack here.
|
// Note that this is ok, as updateSize() does nothing if the
|
||||||
if (parseFloat(navigator.appVersion.split("MSIE")[1]) < 9) {
|
// map's size has not actually changed.
|
||||||
// If IE < 9, register the resize on the div
|
this.updateSizeDestroy = OpenLayers.Function.bind(this.updateSize,
|
||||||
this.events.register("resize", this, this.updateSize);
|
this);
|
||||||
} else {
|
OpenLayers.Event.observe(window, 'resize',
|
||||||
// Else updateSize on catching the window's resize
|
this.updateSizeDestroy);
|
||||||
// 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
|
// only append link stylesheet if the theme property is set
|
||||||
@@ -753,13 +746,9 @@ OpenLayers.Map = OpenLayers.Class({
|
|||||||
OpenLayers.Event.stopObserving(window, 'unload', this.unloadDestroy);
|
OpenLayers.Event.stopObserving(window, 'unload', this.unloadDestroy);
|
||||||
this.unloadDestroy = null;
|
this.unloadDestroy = null;
|
||||||
|
|
||||||
if (this.autoUpdateSize === true) {
|
if (this.updateSizeDestroy) {
|
||||||
if (this.updateSizeDestroy) {
|
OpenLayers.Event.stopObserving(window, 'resize',
|
||||||
OpenLayers.Event.stopObserving(window, 'resize',
|
this.updateSizeDestroy);
|
||||||
this.updateSizeDestroy);
|
|
||||||
} else {
|
|
||||||
this.events.unregister("resize", this, this.updateSize);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.paddingForPopups = null;
|
this.paddingForPopups = null;
|
||||||
|
|||||||
@@ -2094,20 +2094,7 @@
|
|||||||
t.plan(1);
|
t.plan(1);
|
||||||
OpenLayers.Event.unloadCache();
|
OpenLayers.Event.unloadCache();
|
||||||
var resizeListener = false;
|
var resizeListener = false;
|
||||||
var register = OpenLayers.Events.prototype.register;
|
|
||||||
OpenLayers.Events.prototype.register = function(name, el , func) {
|
|
||||||
if (name === 'resize') {
|
|
||||||
resizeListener = true;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
var map = new OpenLayers.Map({
|
var map = new OpenLayers.Map({
|
||||||
events: {
|
|
||||||
register: function(name, el, func) {
|
|
||||||
if (name === 'resize') {
|
|
||||||
resizeListener = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
autoUpdateSize: false,
|
autoUpdateSize: false,
|
||||||
div: 'map',
|
div: 'map',
|
||||||
layers: [
|
layers: [
|
||||||
@@ -2129,7 +2116,6 @@
|
|||||||
}
|
}
|
||||||
t.eq(resizeListener, map.autoUpdateSize, "resize listener not registered when autoUpdateSize is false");
|
t.eq(resizeListener, map.autoUpdateSize, "resize listener not registered when autoUpdateSize is false");
|
||||||
map.destroy();
|
map.destroy();
|
||||||
OpenLayers.Events.prototype.register = register;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Reference in New Issue
Block a user