Skip to content

Commit

Permalink
Merge pull request #5 from omer-biz/circular_scrolling
Browse files Browse the repository at this point in the history
add circular scrolling to the list of images.
  • Loading branch information
ksk001100 authored Oct 9, 2023
2 parents 00d936c + 58ec195 commit eff0b71
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 eff0b71

Please sign in to comment.