Skip to content

Commit

Permalink
fix: overlapping year marks
Browse files Browse the repository at this point in the history
  • Loading branch information
spectrachrome committed Nov 9, 2023
1 parent a1502eb commit ea2e8cf
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions app/src/components/map/SliderTicks.vue
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,8 @@ export default {
this.lines.forEach((line, index) => {
const currentTime = DateTime.fromISO(this.times[index].value);
console.log(currentTime);
const currentYear = currentTime.year;
console.log(`Current year: ${currentYear} | Previous year: ${previousYear}`);
// If it's the first tick or if the year has changed, add a year mark
if (index === 0 || currentYear !== previousYear) {
yearMarks.push({
Expand All @@ -91,6 +88,16 @@ export default {
previousYear = currentYear;
});
// Filter out year marks that are too close together, in favor of the second one.
return yearMarks.filter((current, i) => {
const next = yearMarks[i + 1];
if (next && next.position - current.position < 20) {
return false;
} else {

Check failure on line 96 in app/src/components/map/SliderTicks.vue

View workflow job for this annotation

GitHub Actions / deploy

Unnecessary 'else' after 'return'
return true;
}
});
return yearMarks;

Check failure on line 101 in app/src/components/map/SliderTicks.vue

View workflow job for this annotation

GitHub Actions / deploy

Unreachable code
},
},
Expand Down

0 comments on commit ea2e8cf

Please sign in to comment.