如何像Trello那样重新排列卡片和列表?

我正在尝试对卡片进行重新排列,例如Trello。

我在How does Trello handle rearrangement of cards,lists,checklists etcWhat does the POS actually mean in the Trello API处了解了它的工作方式

每个位置均以65,535开头,并以最后一个位置+ 65,535创建新的卡片或列表,例如:

卡列表

{ "_id" : ObjectId("5e7ea117e13673ec0db43104"),"name" : "A","position" : 65.535 }
{ "_id" : ObjectId("5e7ea117e13673ec0db43105"),"name" : "B","position" : 131.071 }
{ "_id" : ObjectId("5e7ea117e13673ec0db43106"),"name" : "C","position" : 196.607 }
{ "_id" : ObjectId("5e7ea117e13673ec0db43107"),"name" : "D","position" : 262.143 }
{ "_id" : ObjectId("5e7ea117e13673ec0db43108"),"name" : "E","position" : 327.679 }

如果卡片E插入卡片A的顶部,它将被2除(65,535 / 2 = 32,767)

如果卡片A插入卡片E的底部,则其总和为65,535(327,679 + 65,535 = 393,214)

在中间,两个相邻位置的位置平均值。

问题是,如何将任何位置更改为倒数第二个位置?在D和E之间?还是在A和B之间?

如果将卡A插入卡D和E之间,或者将卡E插入A和B之间,这是什么逻辑?

有更好的方法吗?

cl11533248 回答:如何像Trello那样重新排列卡片和列表?

您也可以使用 Lexorank 算法。这就是 Jira 处理卡片订购的方式https://www.youtube.com/watch?v=OjQv9xMoFbg&feature=youtu.be

您可以在 GitHub 中找到 Lexorank 的多个实现。例如,这是 Lexorank https://github.com/acadea/lexorank

的一个简单 JavaScript 实现
本文链接:https://www.f2er.com/2564583.html

大家都在问