Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $window.on('resize', function () {
- adjustGameContainerSize($iframe, payload.gameWidthRatio)
- });
- function adjustGameContainerSize($container, ratio){
- var containerHeight = getGameContainerHeight();
- // Adjusting iframe size
- if (ratio > 0) {
- var containerWidth = getGameContainerWidth(containerHeight, ratio);
- var iframeMaximumWidth = $window.width();
- // Checking whether the computed with is within the boundary
- if (containerWidth > iframeMaximumWidth) {
- // Reduce the height of the iframe
- containerHeight = containerHeight * (iframeMaximumWidth / containerWidth);
- // JUST then overwrite the iframe width
- containerWidth = iframeMaximumWidth;
- }
- $container.width(containerWidth);
- }
- $container.height(containerHeight);
- }
- function getGameContainerHeight(){
- var iframeExtraMargin = 20;
- return $window.height() - $infoBar.height() - iframeExtraMargin;
- }
- function getGameContainerWidth(height, ratio){
- return height * ratio;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement