Repair event grid scaling when there are many events per day.
This commit is contained in:
@@ -3,8 +3,13 @@
|
|||||||
<div
|
<div
|
||||||
v-for="seg in eventSegments"
|
v-for="seg in eventSegments"
|
||||||
:key="'seg-' + seg.startIdx + '-' + seg.endIdx"
|
:key="'seg-' + seg.startIdx + '-' + seg.endIdx"
|
||||||
:class="['segment-grid', { compress: isSegmentCompressed(seg) }]"
|
class="segment-grid"
|
||||||
:style="segmentStyle(seg)"
|
:style="{
|
||||||
|
...segmentStyle(seg),
|
||||||
|
'--segment-row-height': getSegmentRowHeight(seg),
|
||||||
|
'--segment-scale-factor': getSegmentScaleFactor(seg),
|
||||||
|
height: getSegmentTotalHeight(seg)
|
||||||
|
}"
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
v-for="span in seg.events"
|
v-for="span in seg.events"
|
||||||
@@ -179,8 +184,19 @@ function segmentKey(seg) {
|
|||||||
return seg.startIdx + '-' + seg.endIdx
|
return seg.startIdx + '-' + seg.endIdx
|
||||||
}
|
}
|
||||||
|
|
||||||
function isSegmentCompressed(seg) {
|
function getSegmentRowHeight(seg) {
|
||||||
return !!segmentCompression.value[segmentKey(seg)]
|
const data = segmentCompression.value[segmentKey(seg)]
|
||||||
|
return data && typeof data.rowHeight === 'number' ? `${data.rowHeight}px` : '1.5em'
|
||||||
|
}
|
||||||
|
|
||||||
|
function getSegmentTotalHeight(seg) {
|
||||||
|
const data = segmentCompression.value[segmentKey(seg)]
|
||||||
|
return data && typeof data.totalHeight === 'number' ? `${data.totalHeight}px` : 'auto'
|
||||||
|
}
|
||||||
|
|
||||||
|
function getSegmentScaleFactor(seg) {
|
||||||
|
const data = segmentCompression.value[segmentKey(seg)]
|
||||||
|
return data && typeof data.scaleFactor === 'number' ? data.scaleFactor : 1.0
|
||||||
}
|
}
|
||||||
|
|
||||||
function recomputeCompression() {
|
function recomputeCompression() {
|
||||||
@@ -195,8 +211,31 @@ function recomputeCompression() {
|
|||||||
const usable = Math.max(0, available - marginTop)
|
const usable = Math.max(0, available - marginTop)
|
||||||
const nextMap = {}
|
const nextMap = {}
|
||||||
for (const seg of eventSegments.value) {
|
for (const seg of eventSegments.value) {
|
||||||
const desired = (seg.rowsCount || 1) * baseRowPx
|
const rowCount = seg.rowsCount || 1
|
||||||
nextMap[segmentKey(seg)] = desired > usable
|
const gapPx = 2 // gap between grid rows
|
||||||
|
const totalGaps = Math.max(0, rowCount - 1) * gapPx
|
||||||
|
const desired = rowCount * baseRowPx + totalGaps
|
||||||
|
const needsScaling = desired > usable
|
||||||
|
if (needsScaling) {
|
||||||
|
// Calculate the scaled row height that fits within available space
|
||||||
|
const availableForRows = usable - totalGaps
|
||||||
|
const scaledRowHeight = Math.max(0, availableForRows) / rowCount
|
||||||
|
// Never scale larger than the base size
|
||||||
|
const finalRowHeight = Math.min(scaledRowHeight, baseRowPx)
|
||||||
|
const scaleFactor = finalRowHeight / baseRowPx
|
||||||
|
nextMap[segmentKey(seg)] = {
|
||||||
|
rowHeight: finalRowHeight,
|
||||||
|
totalHeight: finalRowHeight * rowCount + totalGaps,
|
||||||
|
scaleFactor: scaleFactor
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Use base size when there's enough space
|
||||||
|
nextMap[segmentKey(seg)] = {
|
||||||
|
rowHeight: baseRowPx,
|
||||||
|
totalHeight: desired,
|
||||||
|
scaleFactor: 1.0
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
segmentCompression.value = nextMap
|
segmentCompression.value = nextMap
|
||||||
}
|
}
|
||||||
@@ -542,16 +581,13 @@ function applyRangeDuringDrag(st, startDate, endDate) {
|
|||||||
pointer-events: none;
|
pointer-events: none;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
grid-auto-columns: 1fr;
|
grid-auto-columns: 1fr;
|
||||||
grid-auto-rows: 1.5em;
|
grid-auto-rows: var(--segment-row-height, 1.5em);
|
||||||
}
|
|
||||||
.segment-grid.compress {
|
|
||||||
grid-auto-rows: 1fr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.event-span {
|
.event-span {
|
||||||
padding: 0.1em 0.3em;
|
padding: calc(0.1em * var(--segment-scale-factor, 1)) calc(0.3em * var(--segment-scale-factor, 1));
|
||||||
border-radius: 1em;
|
border-radius: calc(1em * var(--segment-scale-factor, 1));
|
||||||
font-size: clamp(0.45em, 1.8vh, 0.75em);
|
font-size: calc(clamp(0.45em, 1.8vh, 0.75em) * var(--segment-scale-factor, 1));
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
cursor: grab;
|
cursor: grab;
|
||||||
pointer-events: auto;
|
pointer-events: auto;
|
||||||
|
|||||||
Reference in New Issue
Block a user