Automatic Vimeo aspect ratio

This commit is contained in:
Sam Potts
2017-11-06 22:00:00 +11:00
parent 2497e25b3c
commit 84505da84b
7 changed files with 33 additions and 12 deletions

View File

@ -18,8 +18,7 @@ const youtube = {
utils.toggleClass(this.elements.wrapper, this.config.classNames.embed, true);
// Set aspect ratio
const ratio = this.config.ratio.split(':');
this.elements.wrapper.style.paddingBottom = `${100 / ratio[0] * ratio[1]}%`;
youtube.setAspectRatio.call(this);
// Set ID
this.media.setAttribute('id', utils.generateId(this.type));
@ -48,6 +47,12 @@ const youtube = {
}
},
// Set aspect ratio
setAspectRatio() {
const ratio = this.config.ratio.split(':');
this.elements.wrapper.style.paddingBottom = `${100 / ratio[0] * ratio[1]}%`;
},
// API ready
ready(videoId) {
const player = this;