Deal with ol.global issues
This commit is contained in:
@@ -553,6 +553,7 @@ ol.Map.prototype.removePreRenderFunction = function(preRenderFunction) {
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.Map.prototype.disposeInternal = function() {
|
||||
var global = ol.global;
|
||||
this.mapBrowserEventHandler_.dispose();
|
||||
this.renderer_.dispose();
|
||||
ol.events.unlisten(this.viewport_, ol.events.EventType.WHEEL,
|
||||
@@ -560,12 +561,12 @@ ol.Map.prototype.disposeInternal = function() {
|
||||
ol.events.unlisten(this.viewport_, ol.events.EventType.MOUSEWHEEL,
|
||||
this.handleBrowserEvent, this);
|
||||
if (this.handleResize_ !== undefined) {
|
||||
ol.global.removeEventListener(ol.events.EventType.RESIZE,
|
||||
global.removeEventListener(ol.events.EventType.RESIZE,
|
||||
this.handleResize_, false);
|
||||
this.handleResize_ = undefined;
|
||||
}
|
||||
if (this.animationDelayKey_) {
|
||||
ol.global.cancelAnimationFrame(this.animationDelayKey_);
|
||||
global.cancelAnimationFrame(this.animationDelayKey_);
|
||||
this.animationDelayKey_ = undefined;
|
||||
}
|
||||
this.setTarget(null);
|
||||
@@ -1039,6 +1040,7 @@ ol.Map.prototype.handleSizeChanged_ = function() {
|
||||
* @private
|
||||
*/
|
||||
ol.Map.prototype.handleTargetChanged_ = function() {
|
||||
var global = ol.global;
|
||||
// target may be undefined, null, a string or an Element.
|
||||
// If it's a string we convert it to an Element before proceeding.
|
||||
// If it's not now an Element we remove the viewport from the DOM.
|
||||
@@ -1061,7 +1063,7 @@ ol.Map.prototype.handleTargetChanged_ = function() {
|
||||
if (!targetElement) {
|
||||
ol.dom.removeNode(this.viewport_);
|
||||
if (this.handleResize_ !== undefined) {
|
||||
ol.global.removeEventListener(ol.events.EventType.RESIZE,
|
||||
global.removeEventListener(ol.events.EventType.RESIZE,
|
||||
this.handleResize_, false);
|
||||
this.handleResize_ = undefined;
|
||||
}
|
||||
@@ -1079,7 +1081,7 @@ ol.Map.prototype.handleTargetChanged_ = function() {
|
||||
|
||||
if (!this.handleResize_) {
|
||||
this.handleResize_ = this.updateSize.bind(this);
|
||||
ol.global.addEventListener(ol.events.EventType.RESIZE,
|
||||
global.addEventListener(ol.events.EventType.RESIZE,
|
||||
this.handleResize_, false);
|
||||
}
|
||||
}
|
||||
@@ -1160,8 +1162,9 @@ ol.Map.prototype.isRendered = function() {
|
||||
* @api stable
|
||||
*/
|
||||
ol.Map.prototype.renderSync = function() {
|
||||
var global = ol.global;
|
||||
if (this.animationDelayKey_) {
|
||||
ol.global.cancelAnimationFrame(this.animationDelayKey_);
|
||||
global.cancelAnimationFrame(this.animationDelayKey_);
|
||||
}
|
||||
this.animationDelay_();
|
||||
};
|
||||
@@ -1172,8 +1175,9 @@ ol.Map.prototype.renderSync = function() {
|
||||
* @api stable
|
||||
*/
|
||||
ol.Map.prototype.render = function() {
|
||||
var global = ol.global;
|
||||
if (this.animationDelayKey_ === undefined) {
|
||||
this.animationDelayKey_ = ol.global.requestAnimationFrame(
|
||||
this.animationDelayKey_ = global.requestAnimationFrame(
|
||||
this.animationDelay_);
|
||||
}
|
||||
};
|
||||
@@ -1380,12 +1384,13 @@ ol.Map.prototype.skipFeature = function(feature) {
|
||||
* @api stable
|
||||
*/
|
||||
ol.Map.prototype.updateSize = function() {
|
||||
var global = ol.global;
|
||||
var targetElement = this.getTargetElement();
|
||||
|
||||
if (!targetElement) {
|
||||
this.setSize(undefined);
|
||||
} else {
|
||||
var computedStyle = ol.global.getComputedStyle(targetElement);
|
||||
var computedStyle = global.getComputedStyle(targetElement);
|
||||
this.setSize([
|
||||
targetElement.offsetWidth -
|
||||
parseFloat(computedStyle['borderLeftWidth']) -
|
||||
|
||||
Reference in New Issue
Block a user