mirror of
https://github.com/livebook-dev/livebook.git
synced 2025-03-04 02:43:09 +08:00
Scroll to section when moved (#226)
This commit is contained in:
parent
44eda43d02
commit
04edc75181
2 changed files with 10 additions and 3 deletions
|
@ -509,9 +509,8 @@ function handleSectionDeleted(hook, sectionId) {
|
|||
}
|
||||
|
||||
function handleSectionMoved(hook, sectionId) {
|
||||
if (hook.state.focusedSectionId === sectionId) {
|
||||
globalPubSub.broadcast("session", { type: "section_moved", sectionId });
|
||||
}
|
||||
const section = getSectionById(sectionId);
|
||||
smoothlyScrollToElement(section);
|
||||
}
|
||||
|
||||
function handleCellUpload(hook, cellId, url) {
|
||||
|
|
|
@ -459,6 +459,14 @@ defmodule LivebookWeb.SessionLive do
|
|||
end
|
||||
end
|
||||
|
||||
defp after_operation(socket, _prev_socket, {:move_section, client_pid, section_id, _offset}) do
|
||||
if client_pid == self() do
|
||||
push_event(socket, "section_moved", %{section_id: section_id})
|
||||
else
|
||||
socket
|
||||
end
|
||||
end
|
||||
|
||||
defp after_operation(socket, _prev_socket, _operation), do: socket
|
||||
|
||||
defp handle_actions(socket, actions) do
|
||||
|
|
Loading…
Reference in a new issue