File tree Expand file tree Collapse file tree 2 files changed +14
-4
lines changed Expand file tree Collapse file tree 2 files changed +14
-4
lines changed Original file line number Diff line number Diff line change 31
31
.timeline__items-container {
32
32
display : flex;
33
33
flex-direction : column;
34
- gap : var (--gap );
35
34
flex : 1 ;
36
35
}
37
36
51
50
gap : var (--card-offset );
52
51
}
53
52
53
+ .timeline-item : not (: last-child ) {
54
+ margin-bottom : var (--gap );
55
+ }
56
+
54
57
.timeline__items-container--left .timeline-item {
55
58
flex-direction : row-reverse;
56
59
}
Original file line number Diff line number Diff line change @@ -57,9 +57,16 @@ export function Timeline(props: TimelineProps) {
57
57
let leftHeight = leftContainer . current . offsetTop ;
58
58
let rightHeight = rightContainer . current . offsetTop ;
59
59
60
- const defaultMarkerOffset = elements [ 0 ] . marker ?. offsetTop ?? 0 ;
60
+ const [ firstElement ] = elements ;
61
+
62
+ const defaultMarkerOffset = firstElement . marker ?. offsetTop ?? 0 ;
61
63
let nextMarkerOffset = defaultMarkerOffset ;
62
64
65
+ if ( ! firstElement . item ) return ;
66
+
67
+ const { marginBottom } = getComputedStyle ( firstElement . item ) ;
68
+ const gapHeight = parseFloat ( marginBottom ) ;
69
+
63
70
elements . forEach ( ( refs ) => {
64
71
const { item, pointer, marker } = refs ;
65
72
if ( ! item || ! pointer || ! marker ) return ;
@@ -74,10 +81,10 @@ export function Timeline(props: TimelineProps) {
74
81
// defines whether an item should be appended on the left or right side of the timeline
75
82
if ( ( positioning !== 'right' && leftHeight > rightHeight ) || positioning === 'left' ) {
76
83
rightContainer . current ?. appendChild ( item ) ;
77
- rightHeight += item . offsetHeight ;
84
+ rightHeight += item . offsetHeight + gapHeight ;
78
85
} else {
79
86
leftContainer . current ?. appendChild ( item ) ;
80
- leftHeight += item . offsetHeight ;
87
+ leftHeight += item . offsetHeight + gapHeight ;
81
88
}
82
89
} ) ;
83
90
}
You can’t perform that action at this time.
0 commit comments