Merge pull request #5948 from ronikar/master
ImageOverlay accept ImageElement
This commit is contained in:
commit
572938c741
@ -179,9 +179,12 @@ export var ImageOverlay = Layer.extend({
|
||||
},
|
||||
|
||||
_initImage: function () {
|
||||
var img = this._image = DomUtil.create('img',
|
||||
'leaflet-image-layer ' + (this._zoomAnimated ? 'leaflet-zoom-animated ' : '') +
|
||||
(this.options.className || ''));
|
||||
var wasElementSupplied = this._url.tagName === 'IMG';
|
||||
var img = this._image = wasElementSupplied ? this._url : DomUtil.create('img');
|
||||
|
||||
DomUtil.addClass(img, 'leaflet-image-layer');
|
||||
if (this._zoomAnimated) { DomUtil.addClass(img, 'leaflet-zoom-animated'); }
|
||||
if (this.options.className) { DomUtil.addClass(img, this.options.className); }
|
||||
|
||||
img.onselectstart = Util.falseFn;
|
||||
img.onmousemove = Util.falseFn;
|
||||
@ -199,6 +202,11 @@ export var ImageOverlay = Layer.extend({
|
||||
this._updateZIndex();
|
||||
}
|
||||
|
||||
if (wasElementSupplied) {
|
||||
this._url = img.src;
|
||||
return;
|
||||
}
|
||||
|
||||
img.src = this._url;
|
||||
img.alt = this.options.alt;
|
||||
},
|
||||
|
@ -49,7 +49,16 @@ export var VideoOverlay = ImageOverlay.extend({
|
||||
// Fired when the video has finished loading the first frame
|
||||
vid.onloadeddata = Util.bind(this.fire, this, 'load');
|
||||
|
||||
if (wasElementSupplied) { return; }
|
||||
if (wasElementSupplied) {
|
||||
var sourceElements = vid.getElementsByTagName('source');
|
||||
var sources = [];
|
||||
for (var j = 0; j < sourceElements.length; j++) {
|
||||
sources.push(sourceElements[j].src);
|
||||
}
|
||||
|
||||
this._url = (sourceElements.length > 0) ? sources : [vid.src];
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Util.isArray(this._url)) { this._url = [this._url]; }
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user