moved enabled method, comments

This commit is contained in:
mourner 2010-09-21 12:25:23 +03:00
parent 0d9dd1c53b
commit a523cc7c63
3 changed files with 14 additions and 6 deletions

View File

@ -6,5 +6,9 @@ L.Handler = L.Class.extend({
initialize: function(map, enabled) {
this._map = map;
if (enabled) { this.enable(); }
}
},
enabled: function() {
return !!this._enabled;
}
});

View File

@ -1,9 +1,10 @@
/*
* L.Handler.MapDrag makes the map draggable
* L.Handler.MapDrag is used internally by L.Map to make the map draggable.
*/
L.Handler.MapDrag = L.Handler.extend({
enable: function() {
if (this._enabled) { return; }
if (!this._draggable) {
this._draggable = new L.Draggable(this._map._mapPane, this._map._container);
@ -14,10 +15,13 @@ L.Handler.MapDrag = L.Handler.extend({
this._draggable.on('dragend', this._onDragEnd, this);
}
this._draggable.enable();
this._enabled = true;
},
disable: function() {
if (!this._enabled) { return; }
this._draggable.disable();
this._enabled = false;
},
_fireViewLoad: function() {

View File

@ -1,3 +1,7 @@
/*
* L.Handler.TouchZoom is used internally by L.Map to add touch-zooming on Webkit-powered mobile browsers.
*/
L.Handler.TouchZoom = L.Handler.extend({
enable: function() {
@ -12,10 +16,6 @@ L.Handler.TouchZoom = L.Handler.extend({
this._enabled = false;
},
enabled: function() {
return !!this._enabled;
},
_getClientPoint: function(e) {
return new L.Point(e.clientX, e.clientY);
},