Skip to content

Commit

Permalink
Improving the projection of video by setting videoElement style (#6038)
Browse files Browse the repository at this point in the history
* Improving the projection of video by setting videoElement style

* use the improvement only for supported browsers and when user want it

* small fixes + add a note about browser compatibility
  • Loading branch information
ronikar authored and IvanSanchez committed Jan 12, 2019
1 parent ada86aa commit 62ee339
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/layer/VideoOverlay.js
Expand Up @@ -32,7 +32,12 @@ export var VideoOverlay = ImageOverlay.extend({

// @option loop: Boolean = true
// Whether the video will loop back to the beginning when played.
loop: true
loop: true,

// @option keepAspectRatio: Boolean = true
// Whether the video will save aspect ratio after the projection.
// Relevant for supported browsers. Browser compatibility- https://developer.mozilla.org/en-US/docs/Web/CSS/object-fit
keepAspectRatio: true
},

_initImage: function () {
Expand Down Expand Up @@ -62,6 +67,7 @@ export var VideoOverlay = ImageOverlay.extend({

if (!Util.isArray(this._url)) { this._url = [this._url]; }

if (!this.options.keepAspectRatio && vid.style.hasOwnProperty('objectFit')) { vid.style['objectFit'] = 'fill'; }
vid.autoplay = !!this.options.autoplay;
vid.loop = !!this.options.loop;
for (var i = 0; i < this._url.length; i++) {
Expand Down

0 comments on commit 62ee339

Please sign in to comment.