Skip to content

Instantly share code, notes, and snippets.

@jacksteamdev
Created August 21, 2019 19:37
Show Gist options
  • Save jacksteamdev/18c9ec9a7a0a9987296710962a666af6 to your computer and use it in GitHub Desktop.
Save jacksteamdev/18c9ec9a7a0a9987296710962a666af6 to your computer and use it in GitHub Desktop.
Position new popup window on screen
// 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),
})
@jacksteamdev
Copy link
Author

Of course, the size of the window matters. Too big, and the position will look weird.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment