adjust ScrollArea component layout.

This commit is contained in:
Vixalie 2025-02-28 16:17:11 +08:00
parent caacc63289
commit a37c21f7e7
2 changed files with 13 additions and 1 deletions

View File

@ -6,6 +6,12 @@
overflow: hidden;
grid-template-columns: auto calc(var(--spacing) * 3);
grid-template-rows: auto calc(var(--spacing) * 3);
&.hide_thumb_y {
grid-template-columns: auto 0;
}
&.hide_thumb_x {
grid-template-rows: auto 0;
}
}
.content {
grid-column: 1;

View File

@ -1,3 +1,4 @@
import cx from 'clsx';
import { clamp } from 'lodash-es';
import { MouseEvent, RefObject, useEffect, useRef, useState, WheelEvent } from 'react';
import styles from './ScrollArea.module.css';
@ -184,7 +185,12 @@ export function ScrollArea({
}, [children]);
return (
<div className={styles.scroll_area}>
<div
className={cx(
styles.scroll_area,
!yScrollNeeded && styles.hide_thumb_y,
!xScrollNeeded && styles.hide_thumb_x,
)}>
<div className={styles.content} ref={scrollContainerRef} onWheel={(e) => handleWheel(e)}>
{children}
</div>