Skip to content

Commit

Permalink
SDA-4659 - add logic to stack based on start corner (#2191)
Browse files Browse the repository at this point in the history
  • Loading branch information
KiranNiranjan authored Aug 29, 2024
1 parent eeaec13 commit a11f031
Showing 1 changed file with 27 additions and 17 deletions.
44 changes: 27 additions & 17 deletions src/renderer/notification-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,25 +163,36 @@ export default class NotificationHandler {
return;
}

// Set initial position
const posY = this.settings.firstPos.y;

let posY;
const stackOffset = 10; // Vertical offset for each stacked notification

activeNotifications.forEach((notificationWindow, index) => {
if (!windowExists(notificationWindow)) {
return;
}

// Calculate new position for each notification in the stack
const newY = posY + stackOffset * index;

// Keep the x position constant
const newX = this.settings.firstPos.x;
switch (this.settings.startCorner) {
case 'upper-right':
case 'upper-left':
posY = this.settings.firstPos.y;
activeNotifications.forEach((notificationWindow, index) => {
if (!windowExists(notificationWindow)) {
return;
}
const newY = posY + stackOffset * index;
const newX = this.settings.firstPos.x;
this.setWindowPosition(notificationWindow, newX, newY);
});
break;
case 'lower-right':
case 'lower-left':
posY = this.settings.firstPos.y;
activeNotifications.forEach((notificationWindow, index) => {
if (!windowExists(notificationWindow)) {
return;
}
const newY = posY - stackOffset * index;
const newX = this.settings.firstPos.x;
this.setWindowPosition(notificationWindow, newX, newY);
});
break;
}

// Set the position of the notification window
this.setWindowPosition(notificationWindow, newX, newY);
});
this.isNotificationStacked = true;
}

Expand Down Expand Up @@ -214,7 +225,6 @@ export default class NotificationHandler {
break;
case 'lower-right':
case 'lower-left':
default:
cumulativeHeight += height + this.settings.spacing;
newY = this.settings.corner.y - cumulativeHeight;
break;
Expand Down

0 comments on commit a11f031

Please sign in to comment.