chain block click: anchored zoom drill-down, entry mode at max zoom
This commit is contained in:
1 parent
0c5f211f1c
commit
46bf4aa2c3
1 file changed
+40
@@ -304,7 +304,47 @@ function renderChainBlocks(chains) {
|
||||
</div>
|
||||
`;
|
||||
block.querySelector('.block-header').addEventListener('click', () => {
|
||||
if (entryMode) {
|
||||
openModal(null, null, c.chainId);
|
||||
} else if (zoomIndex >= ZOOM_LEVELS.length - 1) {
|
||||
// Already at max zoom (1 Tag) - enter entry mode for the bucket containing this chain
|
||||
const chainMid = new Date((new Date(c.first).getTime() + new Date(c.last).getTime()) / 2);
|
||||
const totalMinutes = (viewTo - viewFrom) / 60000;
|
||||
const bucketMinutes = Math.max(1, Math.round(totalMinutes / BAR_COUNT));
|
||||
const bucketMs = bucketMinutes * 60000;
|
||||
const elapsed = chainMid - viewFrom;
|
||||
const bucketIndex = Math.floor(elapsed / bucketMs);
|
||||
const bucketStart = new Date(viewFrom.getTime() + bucketIndex * bucketMs);
|
||||
const bucketEnd = new Date(bucketStart.getTime() + bucketMs);
|
||||
zoomStack.push({ from: new Date(viewFrom), to: new Date(viewTo), zoom: zoomIndex, entry: false });
|
||||
viewFrom = bucketStart;
|
||||
viewTo = bucketEnd;
|
||||
entryMode = true;
|
||||
loadView();
|
||||
} else {
|
||||
const chainMid = new Date((new Date(c.first).getTime() + new Date(c.last).getTime()) / 2);
|
||||
zoomStack.push({ from: new Date(viewFrom), to: new Date(viewTo), zoom: zoomIndex, entry: false });
|
||||
const nextZoom = Math.min(zoomIndex + 1, ZOOM_LEVELS.length - 1);
|
||||
const nextLevel = ZOOM_LEVELS[nextZoom];
|
||||
|
||||
if (nextLevel.weeks) {
|
||||
const anchor = getLastAnchor(chainMid);
|
||||
viewFrom = anchor;
|
||||
viewTo = new Date(anchor.getTime() + nextLevel.weeks * 7 * 86400000);
|
||||
} else {
|
||||
// Day slots within current week
|
||||
const weekStart = getLastAnchor(chainMid);
|
||||
const slotMs = nextLevel.days * 86400000;
|
||||
const elapsed = chainMid - weekStart;
|
||||
const slotIndex = Math.floor(elapsed / slotMs);
|
||||
viewFrom = new Date(weekStart.getTime() + slotIndex * slotMs);
|
||||
viewTo = new Date(viewFrom.getTime() + slotMs);
|
||||
}
|
||||
|
||||
zoomIndex = nextZoom;
|
||||
entryMode = false;
|
||||
loadView();
|
||||
}
|
||||
});
|
||||
container.appendChild(block);
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user