问题
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