Created
October 4, 2022 13:40
-
-
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?...
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
// 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)); | |
} | |
}; |
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
/** | |
* 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