rely on registerDisposable

This commit is contained in:
Éric Lemoine
2012-07-02 17:33:01 +02:00
parent 946cd33350
commit 410d79faa1
2 changed files with 9 additions and 14 deletions

View File

@@ -108,13 +108,6 @@ ol.Map = function() {
* @type {Element}
*/
this.container_ = null;
/**
* @private
* @type {ol.handler.Drag}
*/
this.dragHandler_ = null;
};
goog.inherits(ol.Map, goog.events.EventTarget);
@@ -472,7 +465,8 @@ ol.Map.prototype.setViewport = function() {
'class': 'ol-viewport',
'style': 'width:100%;height:100%;top:0;left:0;position:relative;overflow:hidden'
}));
this.dragHandler_ = new ol.handler.Drag(this, this.viewport_);
var dragHandler = new ol.handler.Drag(this, this.viewport_);
this.registerDisposable(dragHandler);
}
goog.dom.appendChild(this.container_, this.viewport_);
};
@@ -545,7 +539,6 @@ ol.Map.prototype.disposeInternal = function() {
for (var key in this) {
delete this[key];
}
this.dragHandler_.dispose();
};

View File

@@ -12,8 +12,10 @@ goog.require('goog.Disposable');
*/
ol.handler.Drag = function(map, elt) {
this.dragger_ = new goog.fx.Dragger(elt);
this.dragger_.defaultAction = function() {};
var dragger = new goog.fx.Dragger(elt);
this.registerDisposable(dragger);
dragger.defaultAction = function() {};
var prevX = 0, prevY = 0;
@@ -44,11 +46,11 @@ ol.handler.Drag = function(map, elt) {
goog.events.dispatchEvent(map, newE);
};
goog.events.listen(this.dragger_, goog.fx.Dragger.EventType.START,
goog.events.listen(dragger, goog.fx.Dragger.EventType.START,
handleDragStart, false, this);
goog.events.listen(this.dragger_, goog.fx.Dragger.EventType.DRAG,
goog.events.listen(dragger, goog.fx.Dragger.EventType.DRAG,
handleDrag, false, this);
goog.events.listen(this.dragger_, goog.fx.Dragger.EventType.END,
goog.events.listen(dragger, goog.fx.Dragger.EventType.END,
handleDragEnd, false, this);
};
goog.inherits(ol.handler.Drag, goog.Disposable);