Ruben2776 / PicView

Fast, free and customizable image viewer for Windows 10 and 11.
https://picview.org
Other
981 stars 65 forks source link

Cannot Navigate to First Image in Folder #97

Closed Yevrag35 closed 9 months ago

Yevrag35 commented 1 year ago

Describe the bug When opening a folder with at least 2 pictures in it, using the left arrow navigation (keyboard arrow or the arrow in the GUI) will not load the first image in the folder after going to any image that is NOT the first image. No error or crash happens; just no action takes place.

IF looping is enabled, however, it works as expected.

To Reproduce Steps to reproduce the behavior:

  1. Load a folder with at least 2 pictures in it with the app.
  2. The app will successfully load and display the first image in the folder.
  3. Use the right navigation arrows to go to the right just one picture.
  4. After the next image has loaded, attempt to use the navigations button to go back to the first image again.

Expected behavior The first image in the folder should be loaded and displayed.

Additional context The problem comes from the logic in Navigation.cs around lines 95 and 96:

int newIndex = FolderIndex + indexChange;

https://github.com/Ruben2776/PicView/blob/53e18f6952e4e9131e552ebc85e3c82409782eb9/PicView/ChangeImage/Navigation.cs#L96

When the first image in a folder is the target destination, newIndex will be calculated to be 0. Because of the if logic on line 96, when newIndex is less than or equal to 0, the operation will be cancelled.

I think it should be okay to change the comparison to a "less than" instead, but I saw your note about the UI blink so not sure if it's as simple as that.

Cheers.

Ruben2776 commented 1 year ago

Thanks for pointing it out. The note is old and the newer code/newer version of .NET changed it so it no longer applies. It will be fixed in the new version soon.