diff options
Diffstat (limited to 'app/scripts/lib/notification-manager.js')
-rw-r--r-- | app/scripts/lib/notification-manager.js | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/app/scripts/lib/notification-manager.js b/app/scripts/lib/notification-manager.js index 969a9459a..721d109a1 100644 --- a/app/scripts/lib/notification-manager.js +++ b/app/scripts/lib/notification-manager.js @@ -1,7 +1,6 @@ const extension = require('extensionizer') -const height = 620 -const width = 360 - +const NOTIFICATION_HEIGHT = 620 +const NOTIFICATION_WIDTH = 360 class NotificationManager { @@ -26,13 +25,18 @@ class NotificationManager { // bring focus to existing chrome popup extension.windows.update(popup.id, { focused: true }) } else { + const {screenX, screenY, outerWidth, outerHeight} = window + const notificationTop = Math.round(screenY + (outerHeight / 2) - (NOTIFICATION_HEIGHT / 2)) + const notificationLeft = Math.round(screenX + (outerWidth / 2) - (NOTIFICATION_WIDTH / 2)) const cb = (currentPopup) => { this._popupId = currentPopup.id } // create new notification popup const creation = extension.windows.create({ url: 'notification.html', type: 'popup', - width, - height, + width: NOTIFICATION_WIDTH, + height: NOTIFICATION_HEIGHT, + top: Math.max(notificationTop, 0), + left: Math.max(notificationLeft, 0), }, cb) creation && creation.then && creation.then(cb) } |