diff options
| author | Terry Truong <terry06890@gmail.com> | 2022-10-15 12:56:01 +1100 |
|---|---|---|
| committer | Terry Truong <terry06890@gmail.com> | 2022-10-15 12:58:55 +1100 |
| commit | f06321dea2738e339f83c8cc08e9fa829e0da0d4 (patch) | |
| tree | 9c6539589a5982203cd5e5dd986e8b7dbddcba0e /src/components/TimeLine.vue | |
| parent | 37c4267ff74ce75d3de5c00a2e9febfc21c00a33 (diff) | |
Fix more bugs due to not excluding 0 CE
Diffstat (limited to 'src/components/TimeLine.vue')
| -rw-r--r-- | src/components/TimeLine.vue | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/components/TimeLine.vue b/src/components/TimeLine.vue index 0c0e6d6..8301dba 100644 --- a/src/components/TimeLine.vue +++ b/src/components/TimeLine.vue @@ -414,6 +414,8 @@ function zoomTimeline(zoomRatio: number){ newStartOffset /= oldUnitsPerNew; newEndOffset /= oldUnitsPerNew; // Shift starting and ending points to align with new scale + // Note: There is some distortion due to not accounting for no year 0 CE here + // But the result seems tolerable, and resolving it adds a fair bit of code complexity let newStartSubUnits = (scale.value == DAY_SCALE) ? getDaysInMonth(newStart.year, newStart.month) : (scale.value == MONTH_SCALE) ? 12 : @@ -455,6 +457,13 @@ function zoomTimeline(zoomRatio: number){ } else { newStart.year = Math.floor(newStart.year / newScale) * newScale; newEnd.year = Math.floor(newEnd.year / newScale) * newScale; + // Account for no 0 CE + if (newStart.year == 0){ + newStart.year = 1; + } + if (newEnd.year == 0){ + newEnd.year = 1; + } } // scaleIdx.value -= 1; |
