Created
December 19, 2019 12:50
-
-
Save estruyf/c308dc012fcf2d802c98247f6c38d605 to your computer and use it in GitHub Desktop.
Focal data of header image
This file contains hidden or 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
| 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