Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improving the projection of video by setting videoElement style #6038

Merged
merged 3 commits into from Jan 12, 2019
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/layer/VideoOverlay.js
Expand Up @@ -32,7 +32,11 @@ 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 saveAspectRatio: Boolean = true
// Whether the video will save aspect ratio after the projection.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please change the name to keepAspectRatio here? Also adding a note about browser compatibility would be good.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where need i to add a note about browser compatibility?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In these comments. Something like

// Whether the video will keep its original aspect ratio. Setting it to `false`
// only has effect on browsers which implement the 
// [`object-fit` CSS property](https://developer.mozilla.org/en-US/docs/Web/CSS/object-fit)".

saveAspectRatio: true
},

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

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

if (!this.options.saveAspectRatio && 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