Skip to content

Commit 58d63e0

Browse files
committed
fix: fix marker position calculation to be more precise
1 parent 9767a08 commit 58d63e0

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

components/Timeline.tsx

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { Card } from '@/components/ui/primitives';
2-
import { getCurrentDate } from '@/lib/utils';
32
import { timelineData, TIMELINE_CONFIG } from '@/data/timeline';
43

54
type TimelineDate = {
@@ -11,7 +10,7 @@ const getTimelineDate = (): TimelineDate => {
1110
const date = new Date();
1211
return {
1312
year: date.getFullYear(),
14-
month: 12,
13+
month: date.getMonth() + 1,
1514
};
1615
};
1716

@@ -23,11 +22,11 @@ const getMonthsSinceStart = (date: TimelineDate) => {
2322
// Helper function to calculate grid position percentage
2423
const getGridOffsetPercentage = (date: TimelineDate) => {
2524
const currentMonths = getMonthsSinceStart(date);
25+
// Use the same calculation as timeline bars for consistency
26+
const totalMonths = TIMELINE_CONFIG.TOTAL_MONTHS + 12;
27+
const percentage = (currentMonths / totalMonths) * 100;
2628

27-
// Adjust for grid
28-
// Each column represents 12 months, so we need to map the percentage to the grid
29-
const gridOffset = (currentMonths / 12) / (TIMELINE_CONFIG.END_YEAR - TIMELINE_CONFIG.START_YEAR + 1) * 100;
30-
return gridOffset;
29+
return percentage;
3130
}
3231

3332
const getGridRange = (

0 commit comments

Comments
 (0)