diff options
author | crupest <crupest@outlook.com> | 2021-01-03 18:49:32 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2021-01-03 18:49:32 +0800 |
commit | 79dbad6f92d105fc541f2035d317de7a547c3441 (patch) | |
tree | 7b9423a86a7d1d9ee3733e6594e58bc5b64b9f9e /FrontEnd/src/app/views/home/TimelineBoard.tsx | |
parent | 7c6d41c8ac02958c0ba98e6879513c958af6249d (diff) | |
download | timeline-79dbad6f92d105fc541f2035d317de7a547c3441.tar.gz timeline-79dbad6f92d105fc541f2035d317de7a547c3441.tar.bz2 timeline-79dbad6f92d105fc541f2035d317de7a547c3441.zip |
...
Diffstat (limited to 'FrontEnd/src/app/views/home/TimelineBoard.tsx')
-rw-r--r-- | FrontEnd/src/app/views/home/TimelineBoard.tsx | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/FrontEnd/src/app/views/home/TimelineBoard.tsx b/FrontEnd/src/app/views/home/TimelineBoard.tsx index 120083e3..bb3f5947 100644 --- a/FrontEnd/src/app/views/home/TimelineBoard.tsx +++ b/FrontEnd/src/app/views/home/TimelineBoard.tsx @@ -100,6 +100,7 @@ const TimelineBoardItem: React.FC<TimelineBoardItemProps> = ({ interface TimelineBoardItemContainerProps { timelines: TimelineInfo[]; editHandler?: { + // offset may exceed index range plusing index. onMove: (timeline: string, index: number, offset: number) => void; onDelete: (timeline: string) => void; }; @@ -277,7 +278,21 @@ const TimelineBoardUI: React.FC<TimelineBoardUIProps> = (props) => { return ( <TimelineBoardItemContainer timelines={timelines} - editHandler={editHandler && editing ? editHandler : undefined} + editHandler={ + editHandler && editing + ? { + onDelete: editHandler.onDelete, + onMove: (timeline, index, offset) => { + if (index + offset >= timelines.length) { + offset = timelines.length - index - 1; + } else if (index + offset < 0) { + offset = -index; + } + editHandler.onMove(timeline, index, offset); + }, + } + : undefined + } /> ); } |