How to rearrange cards and lists like Trello?

拈花ヽ惹草 提交于 2020-04-17 18:33:26

问题


I'm trying to create a rearrangement of cards, lists like Trello.

I read about how it does here How does Trello handle rearrangement of cards, lists, checklists etc and here What does the POS actually mean in the Trello API

Each position starts with the value 65,535 and creates a new card or list with the last position + 65,535, for example:

Card List

{ "_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 }

If Card E is inserted at the top of Card A, it will be divided by 2 (65,535 / 2 = 32,767)

If Card A is inserted at bottom of Card E, it adds up to the value of 65,535 (327,679 + 65,535 = 393,214)

In the middle, the position average of two adjacent positions.

The problem is, how can I change any position to the penultimate position? between D and E? Or between A and B?

If card A is inserted between cards D and E, Or insert Card E between A and B what logic is it to do this?

Is there a better way to do this?

来源:https://stackoverflow.com/questions/60896229/how-to-rearrange-cards-and-lists-like-trello

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!