Skip to content

Commit a6611a7

Browse files
committed
fix: 🐛 cursor masScaleCount limit
1 parent b5c33b6 commit a6611a7

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

src/components/cursor/cursor.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ export const Cursor: FC<CursorProps> = ({
3232
scrollLeft,
3333
scrollSync,
3434
areaRef,
35+
maxScaleCount,
3536
deltaScrollLeft,
3637
onCursorDragStart,
3738
onCursorDrag,
@@ -54,7 +55,7 @@ export const Cursor: FC<CursorProps> = ({
5455
parentRef={areaRef}
5556
bounds={{
5657
left: 0,
57-
right: timelineWidth,
58+
right: Math.min(timelineWidth, maxScaleCount * scaleWidth + startLeft - scrollLeft),
5859
}}
5960
deltaScrollLeft={deltaScrollLeft}
6061
enableDragging={!disableDrag}

src/components/time_area/time_area.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export type TimeAreaProps = CommonProp & {
1616
};
1717

1818
/** 动画时间轴组件 */
19-
export const TimeArea: FC<TimeAreaProps> = ({ setCursor, hideCursor, scale, scaleWidth, scaleCount, scaleSplitCount, startLeft, scrollLeft, onClickTimeArea, getScaleRender }) => {
19+
export const TimeArea: FC<TimeAreaProps> = ({ setCursor, maxScaleCount, hideCursor, scale, scaleWidth, scaleCount, scaleSplitCount, startLeft, scrollLeft, onClickTimeArea, getScaleRender }) => {
2020
const gridRef = useRef<Grid>();
2121
/** 是否显示细分刻度 */
2222
const showUnit = scaleSplitCount > 0;
@@ -73,10 +73,12 @@ export const TimeArea: FC<TimeAreaProps> = ({ setCursor, hideCursor, scale, scal
7373
if (hideCursor) return;
7474
const rect = (e.currentTarget as HTMLElement).getBoundingClientRect();
7575
const position = e.clientX - rect.x;
76+
const left = Math.max(position + scrollLeft, startLeft);
77+
if (left > maxScaleCount * scaleWidth + startLeft - scrollLeft) return;
7678

77-
const time = parserPixelToTime(Math.max(position + scrollLeft, startLeft), { startLeft, scale, scaleWidth });
79+
const time = parserPixelToTime(left, { startLeft, scale, scaleWidth });
7880
const result = onClickTimeArea && onClickTimeArea(time, e);
79-
if(result === false) return; // 返回false时阻止设置时间
81+
if (result === false) return; // 返回false时阻止设置时间
8082
setCursor({ time });
8183
}}
8284
className={prefix('time-area-interact')}

0 commit comments

Comments
 (0)