Skip to content

Commit

Permalink
fixup examples
Browse files Browse the repository at this point in the history
  • Loading branch information
jrmoulton committed Nov 7, 2024
1 parent c0ea2c9 commit d8ec5c5
Show file tree
Hide file tree
Showing 8 changed files with 9 additions and 283 deletions.
8 changes: 0 additions & 8 deletions examples/animations/Cargo.toml

This file was deleted.

31 changes: 0 additions & 31 deletions examples/animations/README.md

This file was deleted.

73 changes: 0 additions & 73 deletions examples/animations/src/main.rs

This file was deleted.

8 changes: 0 additions & 8 deletions examples/draggable/Cargo.toml

This file was deleted.

109 changes: 0 additions & 109 deletions examples/draggable/src/main.rs

This file was deleted.

7 changes: 0 additions & 7 deletions examples/dropped_file/Cargo.toml

This file was deleted.

33 changes: 0 additions & 33 deletions examples/dropped_file/src/main.rs

This file was deleted.

23 changes: 9 additions & 14 deletions examples/widget-gallery/src/draggable.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
use floem::{
keyboard::{Key, NamedKey},
peniko::Color,
reactive::{create_rw_signal, RwSignal, SignalGet, SignalUpdate},
prelude::*,
style::CursorStyle,
views::{dyn_stack, label, Decorators},
IntoView, View,
};

fn sortable_item(
Expand Down Expand Up @@ -35,7 +32,7 @@ fn sortable_item(
floem::event::EventListener::PointerDown,
|_| { /* Disable dragging for this view */ },
),
label(|| "drag me").style(|s| {
text("drag me").style(|s| {
s.selectable(false)
.padding(2)
.cursor(CursorStyle::RowResize)
Expand All @@ -48,16 +45,14 @@ fn sortable_item(
})
.on_event(floem::event::EventListener::DragOver, move |_| {
if dragger_id.get_untracked() != item_id {
let dragger_pos = sortable_items
.get()
.iter()
.position(|id| *id == dragger_id.get_untracked())
.unwrap();
let dragger_pos = sortable_items.with(|items| {
items
.iter()
.position(|id| *id == dragger_id.get_untracked())
.unwrap()
});
let hover_pos = sortable_items
.get()
.iter()
.position(|id| *id == item_id)
.unwrap();
.with(|items| items.iter().position(|id| *id == item_id).unwrap());

sortable_items.update(|items| {
items.remove(dragger_pos);
Expand Down

0 comments on commit d8ec5c5

Please sign in to comment.