|
1 | | -use crate::components::DraggedNode; |
2 | 1 | use crate::components::LocationIndicator; |
3 | 2 | use crate::components::MiniMap; |
4 | 3 | use crate::components::Node; |
@@ -29,13 +28,18 @@ pub fn Mindmap() -> Element { |
29 | 28 | if let Some(parent_id) = node.parent_id { |
30 | 29 | NodeLink { id: node.id, parent_id, store: store.clone() } |
31 | 30 | } |
| 31 | + |
32 | 32 | Node { id: node.id, store: store.clone() } |
33 | 33 | }, |
34 | 34 | )); |
35 | 35 | }); |
36 | 36 | nodes.sort_by_key(|(id, _)| { |
37 | 37 | let root_id = graph.get_root(*id); |
38 | | - (dragging_id != Some(root_id), root_id) |
| 38 | + ( |
| 39 | + dragging_id == Some(*id), |
| 40 | + dragging_id != Some(root_id), |
| 41 | + root_id, |
| 42 | + ) |
39 | 43 | }); |
40 | 44 | rsx! { |
41 | 45 | div { |
@@ -140,7 +144,7 @@ pub fn Mindmap() -> Element { |
140 | 144 | if let Some(dragging_node) = dragging_node { |
141 | 145 | let target = graph.on_other(dragging_node.id, svg_coords); |
142 | 146 | pane.update_drag(svg_coords, target); |
143 | | - graph.move_node(dragging_node.id, dragging_node.coords); |
| 147 | + graph.move_root_node(dragging_node.id, dragging_node.coords); |
144 | 148 | } |
145 | 149 | if *pane.panning.read() { |
146 | 150 | let (start_x, start_y) = *pane.pan_offset.read(); |
@@ -190,22 +194,14 @@ pub fn Mindmap() -> Element { |
190 | 194 |
|
191 | 195 | if let Some(dragging_node) = *pane.dragging_node.read() { |
192 | 196 | if dragging_node.has_moved { |
193 | | - if let Some(node) = graph.get_node(dragging_node.id) { |
194 | | - if node.parent_id.is_some() { |
195 | | - DraggedNode { |
196 | | - id: node.id, |
197 | | - coords: dragging_node.coords, |
198 | | - } |
199 | | - } |
200 | | - if let Some((_, location)) = dragging_node.target { |
201 | | - g { |
202 | | - transform: format!( |
203 | | - "translate({},{})", |
204 | | - dragging_node.coords.0 + 8.0, |
205 | | - dragging_node.coords.1 - 8.0, |
206 | | - ), |
207 | | - LocationIndicator { location } |
208 | | - } |
| 197 | + if let Some((_, location)) = dragging_node.target { |
| 198 | + g { |
| 199 | + transform: format!( |
| 200 | + "translate({},{})", |
| 201 | + dragging_node.coords.0 + 8.0, |
| 202 | + dragging_node.coords.1 - 8.0, |
| 203 | + ), |
| 204 | + LocationIndicator { location } |
209 | 205 | } |
210 | 206 | } |
211 | 207 | } |
|
0 commit comments