Skip to content

Instantly share code, notes, and snippets.

@ftes
Last active October 4, 2021 14:18
Show Gist options
  • Save ftes/1ea78b4fbb660b546d3e596f9a6039a7 to your computer and use it in GitHub Desktop.
Save ftes/1ea78b4fbb660b546d3e596f9a6039a7 to your computer and use it in GitHub Desktop.
Drag'n'drop on the PETAL(S) stack
defmodule PetalsDragNDropWeb.PageLive do
# ...
@impl true
def render(assigns) do
~F"""
...
<GridWithDragAndDrop
dragged="letter_dragged"
...
>
...
"""
end
# ...
@impl true
def handle_event("letter_dragged", %{"from" => from, "to" => to}, socket) do
to = parse_coordinates(to)
{:noreply, update(socket, :data, fn data -> move(data, from["id"], to) end)}
end
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment