Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save themorgantown/ff44ba8daff24113a4856dd6c38a35ba to your computer and use it in GitHub Desktop.
Save themorgantown/ff44ba8daff24113a4856dd6c38a35ba to your computer and use it in GitHub Desktop.
<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