From 0ed1994a82361874ad83adb2e700923a48ceebb4 Mon Sep 17 00:00:00 2001 From: Chris McCormick Date: Tue, 30 Dec 2025 20:49:56 +0800 Subject: [PATCH] Fix issues with moving cards jank. --- TODO.md | 5 +++-- index.html | 19 +++++++++---------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/TODO.md b/TODO.md index 48ecc06..f3ca93e 100644 --- a/TODO.md +++ b/TODO.md @@ -2,16 +2,17 @@ ## TODO -- [ ] Ability to create, move, remove columns. - [ ] Ability to create a project on the projects select page, including if TODO.md is empty. -- [ ] Plus button in the columns to add a new item, with text input. +- [ ] Ability to create, move, remove columns. - [ ] Minimize the number of times the user is asked for access. If possible ask for all the access required at one time. +- [ ] Plus button in the columns to add a new item, with text input. ## In progress ## Done +- [x] Moving cards around janks the file. - [x] When dragging between columns we should show the insertion point and insert the card at that point. - [x] Dropdown for setting the card as checked/unchecked. - [x] Make it look more the makesprite/concrete.css theme. diff --git a/index.html b/index.html index 198aab1..6d4e316 100644 --- a/index.html +++ b/index.html @@ -467,9 +467,11 @@ const section = state.sections[state.currentSectionIndex]; const targetColumn = section.columns[targetColumnIndex]; const targetColumnIsEmpty = targetColumn.cards.length === 0; + const isInsertingAtBottom = insertPosition === targetColumn.cards.length; console.log('Before move, source line', fromLine, '=', lines[fromLine]); console.log('Target column is empty:', targetColumnIsEmpty); + console.log('Inserting at bottom:', isInsertingAtBottom); const [movedLine] = lines.splice(fromLine, 1); @@ -499,11 +501,6 @@ } lines.splice(actualInsertLine, 0, movedLine); - - const afterLine = actualInsertLine + 1; - if (afterLine >= lines.length || lines[afterLine].trim() !== '') { - lines.splice(afterLine, 0, ''); - } } else { console.log('Inserting at position', insertPosition); const cardBefore = targetColumn.cards[insertPosition - 1]; @@ -524,11 +521,13 @@ lines.splice(actualInsertLine, 0, movedLine); } - const movedLineIndex = lines[actualInsertLine - 1] === movedLine ? actualInsertLine - 1 : actualInsertLine; - const afterLine = movedLineIndex + 1; - if (afterLine >= lines.length || lines[afterLine].trim() !== '') { - console.log('Ensuring blank line after moved item at line', afterLine); - lines.splice(afterLine, 0, ''); + if (isInsertingAtBottom) { + const movedLineIndex = lines[actualInsertLine - 1] === movedLine ? actualInsertLine - 1 : actualInsertLine; + const afterLine = movedLineIndex + 1; + if (afterLine >= lines.length || lines[afterLine].trim() !== '') { + console.log('Inserting at bottom - ensuring blank line after moved item at line', afterLine); + lines.splice(afterLine, 0, ''); + } } } }