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 () {
|
_initImage: function () {
|
||||||
var img = this._image = DomUtil.create('img',
|
var wasElementSupplied = this._url.tagName === 'IMG';
|
||||||
'leaflet-image-layer ' + (this._zoomAnimated ? 'leaflet-zoom-animated ' : '') +
|
var img = this._image = wasElementSupplied ? this._url : DomUtil.create('img');
|
||||||
(this.options.className || ''));
|
|
||||||
|
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.onselectstart = Util.falseFn;
|
||||||
img.onmousemove = Util.falseFn;
|
img.onmousemove = Util.falseFn;
|
||||||
@ -199,6 +202,11 @@ export var ImageOverlay = Layer.extend({
|
|||||||
this._updateZIndex();
|
this._updateZIndex();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (wasElementSupplied) {
|
||||||
|
this._url = img.src;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
img.src = this._url;
|
img.src = this._url;
|
||||||
img.alt = this.options.alt;
|
img.alt = this.options.alt;
|
||||||
},
|
},
|
||||||
|
@ -49,7 +49,16 @@ export var VideoOverlay = ImageOverlay.extend({
|
|||||||
// Fired when the video has finished loading the first frame
|
// Fired when the video has finished loading the first frame
|
||||||
vid.onloadeddata = Util.bind(this.fire, this, 'load');
|
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]; }
|
if (!Util.isArray(this._url)) { this._url = [this._url]; }
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user