1
0
mirror of https://github.com/morris/vanilla-todo.git synced 2025-08-22 13:43:06 +02:00

refactor state

This commit is contained in:
Morris Brodersen
2023-11-26 11:54:04 +01:00
parent 9343da1693
commit 6a640515b2
12 changed files with 209 additions and 203 deletions

View File

@@ -7,9 +7,10 @@
export function AppSortable(el, options) {
let placeholder;
let placeholderSource;
const horizontal = options.direction === 'horizontal';
let currentIndex = -1;
const isBefore = options.direction === 'horizontal' ? isLeft : isAbove;
el.addEventListener('draggableStart', (e) =>
e.detail.image.addEventListener('draggableCancel', cleanUp),
);
@@ -115,7 +116,6 @@ export function AppSortable(el, options) {
function calculateIndex(image) {
if (el.children.length === 0) return 0;
const isBefore = horizontal ? isLeft : isAbove;
const rect = image.getBoundingClientRect();
let p = 0;