Skip to content

Commit 10691d7

Browse files
authored
Merge pull request #6271 from whymarrh/centre-notificatons
Centre all notification popups
2 parents 4812fdb + 5bf8a36 commit 10691d7

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

app/scripts/lib/notification-manager.js

+10-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
const extension = require('extensionizer')
2-
const height = 620
3-
const width = 360
4-
2+
const NOTIFICATION_HEIGHT = 620
3+
const NOTIFICATION_WIDTH = 360
54

65
class NotificationManager {
76

@@ -26,13 +25,19 @@ class NotificationManager {
2625
// bring focus to existing chrome popup
2726
extension.windows.update(popup.id, { focused: true })
2827
} else {
28+
const screenWidth = window.screen.width
29+
const screenHeight = window.screen.height
30+
const notificationTop = (screenHeight / 2) - (NOTIFICATION_HEIGHT / 2)
31+
const notificationLeft = (screenWidth / 2) - (NOTIFICATION_WIDTH / 2)
2932
const cb = (currentPopup) => { this._popupId = currentPopup.id }
3033
// create new notification popup
3134
const creation = extension.windows.create({
3235
url: 'notification.html',
3336
type: 'popup',
34-
width,
35-
height,
37+
width: NOTIFICATION_WIDTH,
38+
height: NOTIFICATION_HEIGHT,
39+
top: Math.max(notificationTop, 0),
40+
left: Math.max(notificationLeft, 0),
3641
}, cb)
3742
creation && creation.then && creation.then(cb)
3843
}

0 commit comments

Comments
 (0)