Created
August 21, 2019 19:37
-
-
Save jacksteamdev/18c9ec9a7a0a9987296710962a666af6 to your computer and use it in GitHub Desktop.
Position new popup window on screen
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
// Position by ratio | |
const xPos = 0.75 // 3/4 to the right | |
const yPos = 0.5 // Centered vertically | |
// Size of window | |
const width = 480 | |
const height = 305 | |
// Create window | |
await chromep.windows.create({ | |
type: 'popup', | |
url: 'https://google.com', | |
width, | |
height, | |
top: Math.floor((screen.height - height) * yPos), | |
left: Math.floor((screen.width - width) * xPos), | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Of course, the size of the window matters. Too big, and the position will look weird.