Created
January 24, 2020 02:02
-
-
Save nelsson/57edf1831586319f5b22f51533ffdacd to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function resizePlayer(iframes, ratio) { | |
| if (!iframes[0]) return; | |
| var win = $(".b1"), | |
| width = win.width(), | |
| playerWidth, | |
| height = win.height(), | |
| playerHeight, | |
| ratio = ratio || 16/9; | |
| $(iframes).each(function(){ | |
| var current = $(this); | |
| if (width / ratio < height) { | |
| playerWidth = Math.ceil(height * ratio); | |
| current.width(playerWidth).height(height).css({ | |
| left: (width - playerWidth) / 2 + 10, | |
| top: 12 | |
| }); | |
| } else { | |
| playerHeight = Math.ceil(width / ratio); | |
| current.width(width).height(playerHeight).css({ | |
| left: 0, | |
| top: (height - playerHeight) / 2 | |
| }); | |
| } | |
| }); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment