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 | 723d7b038ad5b3f391c0d6f400f3c12fabf75667 (patch) | |
tree | 5072e92364c4a4bf6fe7782dd00c64777d31aa59 /FrontEnd/src | |
parent | e4950c59e33f81167598b21e69f9b13d352edd36 (diff) | |
download | timeline-723d7b038ad5b3f391c0d6f400f3c12fabf75667.tar.gz timeline-723d7b038ad5b3f391c0d6f400f3c12fabf75667.tar.bz2 timeline-723d7b038ad5b3f391c0d6f400f3c12fabf75667.zip |
...
Diffstat (limited to 'FrontEnd/src')
-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 + } /> ); } |