From 7e8073d6213ea3970f0e4a46e68179c614c5b126 Mon Sep 17 00:00:00 2001 From: Martin Filser Date: Tue, 17 May 2022 00:15:00 +0200 Subject: [PATCH] after moving, e.g. the minicard, round the index to the next integer - before: at index -1 and -9 the new index was -5 - now : at index -1 (or -1.1) and -9 the new index is -2 --- client/lib/utils.js | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/client/lib/utils.js b/client/lib/utils.js index 7c3a18aaa..321ee3090 100644 --- a/client/lib/utils.js +++ b/client/lib/utils.js @@ -343,8 +343,25 @@ Utils = { else { const prevSortIndex = prevData.sort; const nextSortIndex = nextData.sort; - increment = (nextSortIndex - prevSortIndex) / (nItems + 1); - base = prevSortIndex + increment; + if (nItems == 1 ) { + if (prevSortIndex < 0 ) { + const ceil = Math.ceil(nextSortIndex - 1); + if (ceil < nextSortIndex && ceil > prevSortIndex) { + increment = ceil - prevSortIndex; + } + } else { + const floor = Math.floor(nextSortIndex - 1); + if (floor < nextSortIndex && floor > prevSortIndex) { + increment = floor - prevSortIndex; + } + } + } + if (!increment) { + increment = (nextSortIndex - prevSortIndex) / (nItems + 1); + } + if (!base) { + base = prevSortIndex + increment; + } } // XXX Return a generator that yield values instead of a base with a // increment number.