solid-dnd icon indicating copy to clipboard operation
solid-dnd copied to clipboard

how to rotate a SortableProvider / useSortableContext returns null

Open georgfaust opened this issue 10 months ago • 1 comments

I need to rotated a SortableProvider.

In the example https://solid-dnd.com/?example=Sortable%2520list%2520%28vertical%29 I did that like:

<SortableProvider ids={ids()}>
    <div class="flex flex-col w-80 gap-4 mt-40 rotate-[90deg] items-start">
        <For each={items()}>{(item) => <Sortable item={item} />}</For>
    </div>
</SortableProvider>

(https://github.com/georgfaust/solid-dnd-examples/blob/ac61ff21f0a59ba7d8d6dcb295c6c980a2180ee1/src/sortable_list_vertical.jsx#L59C13-L63C32)

This does not work, because the transformer does sth like

delta.x = targetLayout.x - currentLayout.x;
delta.y = targetLayout.y - currentLayout.y;
...
return { x: transform.x + delta.x, y: transform.y + delta.y };

which is not correct due to the rotation of the container.

I could adjust the transformation, but I'd need access to sortableState but useSortableContext always returns null.

  1. is there an easier way than calculating the delta adjusted by the container rotation?
  2. if not, how can I get the sortableState (need initialIds and sortedIds)

georgfaust avatar Apr 23 '24 18:04 georgfaust