Skip to content

Commit

Permalink
add circular scrolling to the list of images.
Browse files Browse the repository at this point in the history
  • Loading branch information
omer-biz committed Oct 8, 2023
1 parent 00d936c commit 58ec195
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions src/app/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,17 +74,28 @@ impl<'a> AppState<'a> {
..
} = self
{
if *selected_index < images.len() - 1 {
*selected_index += 1;
*selected_index += 1;
if *selected_index >= images.len() {
*selected_index = 0;
}
}
}

pub fn decrement_index(&mut self) {
if let Self::Initialized { selected_index, .. } = self {
if *selected_index > 0 {
*selected_index -= 1;
if let Self::Initialized {
selected_index,
paths: images,
..
} = self
{
if images.is_empty() {
return;
}

if *selected_index == 0 {
*selected_index = images.len();
}
*selected_index -= 1;
}
}

Expand Down

0 comments on commit 58ec195

Please sign in to comment.