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 3131.timeline__items-container {
3232 display : flex;
3333 flex-direction : column;
34- gap : var (--gap );
3534 flex : 1 ;
3635}
3736
5150 gap : var (--card-offset );
5251}
5352
53+ .timeline-item : not (: last-child ) {
54+ margin-bottom : var (--gap );
55+ }
56+
5457.timeline__items-container--left .timeline-item {
5558 flex-direction : row-reverse;
5659}
Original file line number Diff line number Diff line change @@ -57,9 +57,16 @@ export function Timeline(props: TimelineProps) {
5757 let leftHeight = leftContainer . current . offsetTop ;
5858 let rightHeight = rightContainer . current . offsetTop ;
5959
60- const defaultMarkerOffset = elements [ 0 ] . marker ?. offsetTop ?? 0 ;
60+ const [ firstElement ] = elements ;
61+
62+ const defaultMarkerOffset = firstElement . marker ?. offsetTop ?? 0 ;
6163 let nextMarkerOffset = defaultMarkerOffset ;
6264
65+ if ( ! firstElement . item ) return ;
66+
67+ const { marginBottom } = getComputedStyle ( firstElement . item ) ;
68+ const gapHeight = parseFloat ( marginBottom ) ;
69+
6370 elements . forEach ( ( refs ) => {
6471 const { item, pointer, marker } = refs ;
6572 if ( ! item || ! pointer || ! marker ) return ;
@@ -74,10 +81,10 @@ export function Timeline(props: TimelineProps) {
7481 // defines whether an item should be appended on the left or right side of the timeline
7582 if ( ( positioning !== 'right' && leftHeight > rightHeight ) || positioning === 'left' ) {
7683 rightContainer . current ?. appendChild ( item ) ;
77- rightHeight += item . offsetHeight ;
84+ rightHeight += item . offsetHeight + gapHeight ;
7885 } else {
7986 leftContainer . current ?. appendChild ( item ) ;
80- leftHeight += item . offsetHeight ;
87+ leftHeight += item . offsetHeight + gapHeight ;
8188 }
8289 } ) ;
8390 }
You can’t perform that action at this time.
0 commit comments