[Q] Sortable: sort items via JS

Dear all,

is there a way to move sortable items via JS?

Purpose: I would like to move items that a selected by the user manually to the top of the list. In case the item is de-selected it should move back to the original position.

The idea is something like:

  1. enable sorting
  2. move selected item to pos x (in x ms) = some JS stuff
  3. disable sorting

Best regards
Andreas

Hi Andreas_Kramling,
If i understand correctly, usr moves a item to the top of the list, (user action). Then user de-select (don’t understand how) the item he just move top. Now that item must go to its original position automatically (JS Stuff)?
If that’s the case, you should store item original position before user move the item. then if user de-select it, move it back to its original pos you previously saved.

Hi,

thanks for your thoughts. To sort the different elements is not the issue.

But instead just to reorder the DOM elements I would like to softly move it (animated).
I was wondering if it possible to misuse the sortable widget for this purpose (to avoid to calculate all the transformations by myself).

Best regards
Andreas

Sorry, i don’t understand the question then. My language is Spanish. Sortable list works as you ask, you just drag the element to the position you want and f7 smoothly rearrange the elements of the list. It only works on Y axis. You also want X axis?
Doc:
https://framework7.io/docs/sortable-list.html

Sorry for the misunderstanding… y-axis is completly fine…

The F7 included rearrangement is initiated by the user (touchmove event) and f7 takes care about the moving of the elements…

What I am looking for (is hoping) that these movements can be triggered via JS as well. But it seems, there isn’t.

Hardcore methode would be to add alls the required transformations by myself (and this I would like to avoid).

Ok, now i get it. No i don’t think f7 do the movement automatically. so you will have to implement it yourself.