|
1 | | -/* global CellSlot Log Slot */ |
| 1 | +/* global CellSlot Slot */ |
2 | 2 | // eslint-disable-next-line no-unused-vars |
3 | 3 | class WeekSlot extends Slot { |
4 | 4 | constructor (view, period, seq = 0) { |
@@ -56,36 +56,15 @@ class WeekSlot extends Slot { |
56 | 56 | return event.dom; |
57 | 57 | } |
58 | 58 |
|
59 | | - // Helper to wait for DOM to be rendered and have correct sizes |
60 | | - async waitForLayout (selector, tries = 10, delay = 30) { |
61 | | - for (let attempt = 0; attempt < tries; attempt++) { |
62 | | - const el = this.contentDom.querySelector(selector); |
63 | | - if (el) { |
64 | | - const rect = el.getBoundingClientRect(); |
65 | | - if (rect.height > 0 && rect.width > 0) { |
66 | | - return rect; |
67 | | - } |
68 | | - } |
69 | | - // eslint-disable-next-line no-await-in-loop, no-promise-executor-return |
70 | | - await new Promise((res) => setTimeout(res, delay)); |
71 | | - } |
72 | | - throw new Error("Element layout not ready"); |
73 | | - } |
| 59 | + drawEvents () { |
| 60 | + // Get the first cellSlot content/header for sizing |
| 61 | + const firstCellContent = this.contentDom.querySelector(".cellSlot .slotContent"); |
| 62 | + const firstCellHeader = this.contentDom.querySelector(".cellSlot .slotHeader"); |
74 | 63 |
|
75 | | - async drawEvents () { |
76 | | - let fcc, fch; |
77 | | - try { |
78 | | - fcc = await this.waitForLayout(".cellSlot .slotContent"); |
79 | | - fch = await this.waitForLayout(".cellSlot .slotHeader"); |
80 | | - } catch (e) { |
81 | | - Log.warn("Layout not ready for drawEvents:", e); |
82 | | - // Fallback to default values if layout is not ready |
83 | | - fcc = {height: 95}; |
84 | | - fch = {height: 28}; |
85 | | - } |
| 64 | + // Use measured heights |
| 65 | + this.timelineDom.style.height = `${firstCellContent.getBoundingClientRect().height}px`; |
| 66 | + this.timelineDom.style.top = `${firstCellHeader.getBoundingClientRect().height}px`; |
86 | 67 |
|
87 | | - this.timelineDom.style.top = `${fch.height}px`; |
88 | | - this.timelineDom.style.height = `${fcc.height}px`; |
89 | 68 | const parentPosition = this.timelineDom.getBoundingClientRect(); |
90 | 69 |
|
91 | 70 | const fcs = this.contentDom.querySelectorAll(".cellSlot"); |
|
0 commit comments