Last active
November 13, 2017 09:24
-
-
Save yoannmoinet/1d1090ebb51136e6168eaa05dbe85e87 to your computer and use it in GitHub Desktop.
Apply a masked circle on element.
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
// Main process | |
export const createSeeThroughWindow = () => { | |
const w = new BrowserWindow({ transparent: true }); | |
w.setIgnoreMouseEvents(true); | |
}; |
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
// Renderer process | |
const mask_radius = 200; | |
export const moveSeeThrough = ({x, y}) => { | |
const $body = document.body; | |
const newX = $body.scrollLeft + x; | |
const newY = $body.scrollTop + y; | |
$body.setAttribute('style', `-webkit-mask-image: radial-gradient( | |
${mask_radius}px at ${newX}px ${newY}px , | |
rgba(0, 0, 0, 0) 0%, | |
rgba(0, 0, 0, 0) 99%, | |
rgba(0, 0, 0, 1) 100% | |
);`); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment