Drag and Drop Alternatives

Hi all,

Big part of my app im moving to native is drag and drop (currently using DragIt for web)

Any ideas how i can move an item in a list to the + or - list index and save it?

Its the main thing stopping the app from launching.

Thanks
Chad

Hey @chaddickson83,

Add a position field (on the DT) for each item in the list, and then display the list sorted by position (descending = no). And then when a user wants to move the items, just swap positions accordingly.

For reference, consider the following items;

  • John = 1
  • Sarah = 2
  • Titus = 3
  • Melissa = 4
  • Tim = 5

Now if a user highlights Titus (position 3) to move upwards to position 2, the the logic steps would be;

  • Update item whose position is (currently selected - 1 = 2) to be currently selected position (which is 3)
  • Update currently selected (which is 3) to be position - 1 (which would now be 2).

Although, this may run into race conditions on very few occasions, and so, as an addition, you may want to force the operations by referencing the previous step (step 2 ref step 1) OR even block user action immediately they tap a button so they don’t do so twice and double-trigger the event.

Hope it helps.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.