Remove global L usage (#5463)

This commit is contained in:
Mstislav Zhivodkov 2017-04-20 17:38:28 +07:00 committed by Per Liedman
parent 561b7f737b
commit cbaf02034c
7 changed files with 25 additions and 21 deletions

View File

@ -108,7 +108,7 @@ export var Layers = Control.extend({
}, },
addTo: function (map) { addTo: function (map) {
L.Control.prototype.addTo.call(this, map); Control.prototype.addTo.call(this, map);
// Trigger expand after Layers Control has been inserted into DOM so that is now has an actual height. // Trigger expand after Layers Control has been inserted into DOM so that is now has an actual height.
return this._expandIfNotCollapsed(); return this._expandIfNotCollapsed();
}, },

View File

@ -114,7 +114,7 @@ Class.addInitHook = function (fn) { // (Function) || (String, args...)
function checkDeprecatedMixinEvents(includes) { function checkDeprecatedMixinEvents(includes) {
if (!L || !L.Mixin) { return; } if (!L || !L.Mixin) { return; }
includes = L.Util.isArray(includes) ? includes : [includes]; includes = Util.isArray(includes) ? includes : [includes];
for (var i = 0; i < includes.length; i++) { for (var i = 0; i < includes.length; i++) {
if (includes[i] === L.Mixin.Events) { if (includes[i] === L.Mixin.Events) {

View File

@ -1,4 +1,6 @@
import {ImageOverlay} from './ImageOverlay'; import {ImageOverlay} from './ImageOverlay';
import * as DomUtil from '../dom/DomUtil';
import * as Util from '../core/Util';
/* /*
* @class VideoOverlay * @class VideoOverlay
@ -34,22 +36,22 @@ export var VideoOverlay = ImageOverlay.extend({
}, },
_initImage: function () { _initImage: function () {
var vid = this._image = L.DomUtil.create('video', var vid = this._image = DomUtil.create('video',
'leaflet-image-layer ' + (this._zoomAnimated ? 'leaflet-zoom-animated' : '')); 'leaflet-image-layer ' + (this._zoomAnimated ? 'leaflet-zoom-animated' : ''));
vid.onselectstart = L.Util.falseFn; vid.onselectstart = Util.falseFn;
vid.onmousemove = L.Util.falseFn; vid.onmousemove = Util.falseFn;
// @event load: Event // @event load: Event
// Fired when the video has finished loading the first frame // Fired when the video has finished loading the first frame
vid.onloadeddata = L.bind(this.fire, this, 'load'); vid.onloadeddata = Util.bind(this.fire, this, 'load');
if (!L.Util.isArray(this._url)) { this._url = [this._url]; } if (!Util.isArray(this._url)) { this._url = [this._url]; }
vid.autoplay = !!this.options.autoplay; vid.autoplay = !!this.options.autoplay;
vid.loop = !!this.options.loop; vid.loop = !!this.options.loop;
for (var i = 0; i < this._url.length; i++) { for (var i = 0; i < this._url.length; i++) {
var source = L.DomUtil.create('source'); var source = DomUtil.create('source');
source.src = this._url[i]; source.src = this._url[i];
vid.appendChild(source); vid.appendChild(source);
} }
@ -65,5 +67,5 @@ export var VideoOverlay = ImageOverlay.extend({
// Instantiates an image overlay object given the URL of the video (or array of URLs) and the // Instantiates an image overlay object given the URL of the video (or array of URLs) and the
// geographical bounds it is tied to. // geographical bounds it is tied to.
export function videoOverlay(url, bounds, options) { export function videoOverlay(url, bounds, options) {
return new L.VideoOverlay(url, bounds, options); return new VideoOverlay(url, bounds, options);
} }

View File

@ -39,7 +39,7 @@ import {Bounds} from '../../geometry/Bounds';
export var Canvas = Renderer.extend({ export var Canvas = Renderer.extend({
getEvents: function () { getEvents: function () {
var events = L.Renderer.prototype.getEvents.call(this); var events = Renderer.prototype.getEvents.call(this);
events.viewprereset = this._onViewPreReset; events.viewprereset = this._onViewPreReset;
return events; return events;
}, },
@ -69,8 +69,8 @@ export var Canvas = Renderer.extend({
_destroyContainer: function () { _destroyContainer: function () {
delete this._ctx; delete this._ctx;
L.DomUtil.remove(this._container); DomUtil.remove(this._container);
L.DomEvent.off(this._container); DomEvent.off(this._container);
delete this._container; delete this._container;
}, },
@ -118,7 +118,7 @@ export var Canvas = Renderer.extend({
}, },
_reset: function () { _reset: function () {
L.Renderer.prototype._reset.call(this); Renderer.prototype._reset.call(this);
if (this._postponeUpdatePaths) { if (this._postponeUpdatePaths) {
this._postponeUpdatePaths = false; this._postponeUpdatePaths = false;

View File

@ -1,6 +1,8 @@
import {Renderer} from './Renderer'; import {Renderer} from './Renderer';
import * as DomUtil from '../../dom/DomUtil'; import * as DomUtil from '../../dom/DomUtil';
import * as DomEvent from '../../dom/DomEvent';
import * as Browser from '../../core/Browser'; import * as Browser from '../../core/Browser';
import {stamp} from '../../core/Util';
import {svgCreate, pointsToPath} from './SVG.Util'; import {svgCreate, pointsToPath} from './SVG.Util';
export {pointsToPath}; export {pointsToPath};
import {vmlMixin, vmlCreate} from './SVG.VML'; import {vmlMixin, vmlCreate} from './SVG.VML';
@ -62,8 +64,8 @@ export var SVG = Renderer.extend({
}, },
_destroyContainer: function () { _destroyContainer: function () {
L.DomUtil.remove(this._container); DomUtil.remove(this._container);
L.DomEvent.off(this._container); DomEvent.off(this._container);
delete this._container; delete this._container;
delete this._rootGroup; delete this._rootGroup;
}, },
@ -115,7 +117,7 @@ export var SVG = Renderer.extend({
} }
this._updateStyle(layer); this._updateStyle(layer);
this._layers[L.stamp(layer)] = layer; this._layers[stamp(layer)] = layer;
}, },
_addPath: function (layer) { _addPath: function (layer) {
@ -127,7 +129,7 @@ export var SVG = Renderer.extend({
_removePath: function (layer) { _removePath: function (layer) {
DomUtil.remove(layer._path); DomUtil.remove(layer._path);
layer.removeInteractiveTarget(layer._path); layer.removeInteractiveTarget(layer._path);
delete this._layers[L.stamp(layer)]; delete this._layers[stamp(layer)];
}, },
_updatePath: function (layer) { _updatePath: function (layer) {

View File

@ -721,7 +721,7 @@ export var Map = Evented.extend({
this._layers[i].remove(); this._layers[i].remove();
} }
for (i in this._panes) { for (i in this._panes) {
L.DomUtil.remove(this._panes[i]); DomUtil.remove(this._panes[i]);
} }
this._layers = []; this._layers = [];
@ -955,7 +955,7 @@ export var Map = Evented.extend({
// value is between -180 and +180 degrees, and the majority of the bounds // value is between -180 and +180 degrees, and the majority of the bounds
// overlaps the CRS's bounds. // overlaps the CRS's bounds.
wrapLatLngBounds: function (latlng) { wrapLatLngBounds: function (latlng) {
return this.options.crs.wrapLatLngBounds(L.latLngBounds(latlng)); return this.options.crs.wrapLatLngBounds(toLatLngBounds(latlng));
}, },
// @method distance(latlng1: LatLng, latlng2: LatLng): Number // @method distance(latlng1: LatLng, latlng2: LatLng): Number
@ -1538,7 +1538,7 @@ export var Map = Evented.extend({
}, },
_destroyAnimProxy: function () { _destroyAnimProxy: function () {
L.DomUtil.remove(this._proxy); DomUtil.remove(this._proxy);
delete this._proxy; delete this._proxy;
}, },

View File

@ -41,7 +41,7 @@ export var BoxZoom = Handler.extend({
}, },
_destroy: function () { _destroy: function () {
L.DomUtil.remove(this._pane); DomUtil.remove(this._pane);
delete this._pane; delete this._pane;
}, },