Created
December 19, 2019 15:29
-
-
Save themorgantown/ff44ba8daff24113a4856dd6c38a35ba 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
<script type="text/javascript"> | |
function myCallback(hypeDocument, element, event) { | |
// optional: | |
// document.getElementById(hypeDocument.documentId()).style["max-width"] = "1100px"; | |
var hypeContainer = document.getElementById(hypeDocument.documentId()); | |
var layoutsOfScene = | |
hypeDocument.layoutsForSceneNamed(hypeDocument.currentSceneName()); | |
var resizeScene = function () { | |
var currLayoutObj = layoutsOfScene.find(arrayElement => arrayElement.name == | |
hypeDocument.currentLayoutName()); | |
var UIWidth = currLayoutObj.width; | |
var UIHeight = currLayoutObj.height; | |
var current_width = document.getElementById(hypeDocument.documentId()).offsetWidth; | |
var new_height = current_width * UIHeight / UIWidth; | |
hypeContainer.style.height = new_height + 'px'; | |
}; | |
if (window.addEventListener) { | |
window.addEventListener('load', resizeScene, false); | |
window.addEventListener('resize', resizeScene, false); | |
} else if (window.attachEvent) { | |
window.attachEvent('onload', resizeScene); | |
window.attachEvent('onresize', resizeScene); | |
} | |
} | |
if ("HYPE_eventListeners" in window === false) { | |
window.HYPE_eventListeners = Array(); | |
} | |
window.HYPE_eventListeners.push({ | |
"type": "HypeDocumentLoad", | |
"callback": myCallback | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment