diff options
| author | Terry Truong <terry06890@gmail.com> | 2023-01-02 16:29:50 +1100 |
|---|---|---|
| committer | Terry Truong <terry06890@gmail.com> | 2023-01-02 16:29:50 +1100 |
| commit | 58cf14fbd369b2d6cfff4cdeac8f9c2ce54db69f (patch) | |
| tree | 4e2b150f4994cbe007e4c4836ef6c3d5b1f0057e | |
| parent | 092d310c5c56dfd9af9de553ddbc6f86b4c957bd (diff) | |
Remove timelines when screen is shrunk enoughremove-on-shrink
| -rw-r--r-- | src/App.vue | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/App.vue b/src/App.vue index 3de3ac2..21d4b55 100644 --- a/src/App.vue +++ b/src/App.vue @@ -47,8 +47,9 @@ import {RBTree, rbtree_shallow_copy} from './rbtree'; // Refs const contentAreaRef = ref(null as HTMLElement | null); -// Global store +// Global constants const store = useStore(); +const MIN_TIMELINE_BREADTH = store.mainlineBreadth + store.spacing * 2 + store.eventImgSz + store.eventLabelHeight; // For content sizing (used to decide between horizontal and vertical mode) const contentWidth = ref(0); @@ -58,6 +59,11 @@ function updateAreaDims(){ let contentAreaEl = contentAreaRef.value!; contentWidth.value = contentAreaEl.offsetWidth; contentHeight.value = contentAreaEl.offsetHeight; + // Check for too many timelines + const majorLen = vert.value ? contentWidth.value : contentHeight.value; + while (majorLen / timelines.value.length < MIN_TIMELINE_BREADTH && timelines.value.length > 1){ + timelines.value.pop(); + } } onMounted(updateAreaDims) @@ -82,10 +88,9 @@ function onTimelineChg(state: TimelineState, idx: number){ } // For timeline addition/removal -const MIN_TIMELINE_BREADTH = store.mainlineBreadth + store.spacing * 2 + store.eventImgSz + store.eventLabelHeight; function onTimelineAdd(){ - if (vert.value && contentWidth.value / (timelines.value.length + 1) < MIN_TIMELINE_BREADTH || - !vert.value && contentHeight.value / (timelines.value.length + 1) < MIN_TIMELINE_BREADTH){ + const majorLen = vert.value ? contentWidth.value : contentHeight.value; + if (majorLen && contentWidth.value / (timelines.value.length + 1) < MIN_TIMELINE_BREADTH){ console.log('Reached timeline minimum breadth'); return; } |
