Skip to content

Instantly share code, notes, and snippets.

@estruyf
Created December 19, 2019 12:50
Show Gist options
  • Select an option

  • Save estruyf/c308dc012fcf2d802c98247f6c38d605 to your computer and use it in GitHub Desktop.

Select an option

Save estruyf/c308dc012fcf2d802c98247f6c38d605 to your computer and use it in GitHub Desktop.
Focal data of header image
const layoutContent = data.LayoutWebpartsContent;
const el = document.createElement('div');
el.innerHTML = layoutContent;
const divElm = el.querySelectorAll("[data-sp-canvascontrol]");
if (divElm && divElm.length > 0) {
const cntlData = divElm[0].getAttribute("data-sp-controldata");
if (cntlData) {
const pCtrlData = JSON.parse(cntlData);
if (pCtrlData && pCtrlData.properties) {
const focalData = {
translateX: pCtrlData.properties.translateX || null,
translateY: pCtrlData.properties.translateY || null
};
// Now you can add the focal data to your images
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment