Skip to content

Commit

Permalink
DEV: Better calculations of list height (#39)
Browse files Browse the repository at this point in the history
  • Loading branch information
janzenisaac authored Dec 20, 2023
1 parent bcf2df8 commit 1af13a0
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions javascripts/discourse/services/kanban-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,16 @@ export default class KanbanManager extends Service {
const mainOutlet = document.querySelector("#main-outlet");
const mainOutletHeight = mainOutlet.getBoundingClientRect().height;
const mainOutletPadding = 40;
const listControlsHeight = mainOutlet
.querySelector(".list-controls")
.getBoundingClientRect().height;

// Get all previous siblings of the list container and add their heights
let currentElement =
mainOutlet.querySelector(".list-container").previousElementSibling;
let previousSiblingsHeight = 0;
while (currentElement !== null) {
previousSiblingsHeight += currentElement.getBoundingClientRect().height;
currentElement = currentElement.previousElementSibling;
}

const listTitleHeight = mainOutlet
.querySelector(".list-title")
.getBoundingClientRect().height;
Expand All @@ -134,7 +141,7 @@ export default class KanbanManager extends Service {
} else {
height =
mainOutletHeight -
listControlsHeight -
previousSiblingsHeight -
listTitleHeight -
mainOutletPadding;
}
Expand Down

0 comments on commit 1af13a0

Please sign in to comment.