Skip to content

Instantly share code, notes, and snippets.

@JohnRSim
Created October 4, 2022 13:40
Show Gist options
  • Save JohnRSim/72db8d204b8d74d3cdfa5076ad0c2961 to your computer and use it in GitHub Desktop.
Save JohnRSim/72db8d204b8d74d3cdfa5076ad0c2961 to your computer and use it in GitHub Desktop.
In settings the custom binding "scsCompComponentImpl" doesn't get executed.. and SitesSDK.setHeight method does not exist?...
// set the iFrame height when we've fully rendered
ko.bindingHandlers.scsCompComponentImpl = {
init: function (element, valueAccessor, allBindings, viewModel, bindingContext) {
var body = document.body,
html = document.documentElement;
SitesSDK.setHeight(Math.max(
body.scrollHeight,
body.offsetHeight,
html.clientHeight,
html.scrollHeight,
html.offsetHeight));
}
};
/**
* updateHeight
* updates settings panel parent iframe height
**/
function updateHeight() {
console.log('[updateHeight]')
var body = document.body,
html = document.documentElement;
if (SitesSDK.setHeight) {
SitesSDK.setHeight(Math.max(
body.scrollHeight,
body.offsetHeight,
html.clientHeight,
html.scrollHeight,
html.offsetHeight));
} else {
/*
//Doesn't work with settings panel
SitesSDK.setProperty('height', Math.max(
body.scrollHeight,
body.offsetHeight,
html.clientHeight,
html.scrollHeight,
html.offsetHeight));*/
//get height of window and parent iframe
const updateHeight = `${Math.max(body.offsetHeight)}px`;
const settingsIframe = window.parent.document.querySelector('iframe.scs-component-settings');
//update heights
settingsIframe.height = updateHeight;
settingsIframe.parentElement.style.maxHeight = updateHeight;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment