Created
July 27, 2016 06:11
-
-
Save ykob/52bf888ec7eec096facf71e166b3d999 to your computer and use it in GitHub Desktop.
This file contains 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
setFullScreen = ($elm, width, height) => { | |
let resize_width = 0; | |
let resize_height = 0; | |
let margin = []; | |
if (window.innerWidth / window.innerHeight > width / height) { | |
resize_width = window.innerWidth; | |
resize_height = height * (window.innerWidth / width); | |
let over = (window.innerHeight - resize_height) / 2; | |
margin = [over, 0, over, 0]; | |
} else { | |
resize_width = width * (window.innerHeight / height); | |
resize_height = window.innerHeight; | |
let over = (window.innerWidth - resize_width) / 2; | |
margin = [0, over, 0, over]; | |
} | |
$elm.css({ | |
width: resize_width, | |
height: resize_height, | |
marginTop: margin[0], | |
marginRight: margin[1], | |
marginBottom: margin[2], | |
marginLeft: margin[3], | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment