Last active
October 4, 2021 14:18
-
-
Save ftes/1ea78b4fbb660b546d3e596f9a6039a7 to your computer and use it in GitHub Desktop.
Drag'n'drop on the PETAL(S) stack
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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