From 0c7e068fcdb69de18903de2cce2a29912729dc89 Mon Sep 17 00:00:00 2001 From: dixso Date: Sun, 8 Jan 2017 19:03:50 +0100 Subject: [PATCH] Bug fix mobile iframe --- src/custombox.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/custombox.ts b/src/custombox.ts index dce9b2b..a3aa43e 100644 --- a/src/custombox.ts +++ b/src/custombox.ts @@ -346,7 +346,7 @@ namespace Custombox { let match = this.options.content.target.match(regExp); if (match && match[2].length == 11) { - let element: any = document.createElement('div'); + const element: any = document.createElement('div'); let frame = document.createElement('iframe'); frame.setAttribute('src', `https://www.youtube.com/embed/${match[2]}`); @@ -357,11 +357,11 @@ namespace Custombox { element.appendChild(frame); if (!this.options.content.fullscreen) { - let w = 560; - let h = 315; + let w = window.innerWidth > 560 ? 560 : window.innerWidth; + let h = window.innerHeight > 315 ? 315 : window.innerHeight; - if (this.options.content.width) { - const natural: number = parseInt(this.options.content.width, 10); + const natural: number = parseInt(this.options.content.width, 10); + if (this.options.content.width && window.innerWidth > natural) { h = Math.round(h * natural / w); w = natural; }