Skip to content

Commit

Permalink
Smoothen skimming with page slider
Browse files Browse the repository at this point in the history
  • Loading branch information
RobbWatershed committed Feb 26, 2023
1 parent 62969d0 commit 2ce290c
Showing 1 changed file with 11 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -181,14 +181,17 @@ void updatePageControls() {
pageMaxNumber.setText(String.format(Locale.ENGLISH, "%d", maxPageNum));
superBinding.viewerPagenumberText.setText(String.format(Locale.ENGLISH, "%d / %d", pageNum, maxPageNum));

int sliderMaxPos = Math.max(1, maxPageNum - 1);
// Next line to avoid setting a max position inferior to current position
binding.pageSlider.setValue(Helper.coerceIn(binding.pageSlider.getValue(), 0, sliderMaxPos));
binding.pageSlider.setValueTo(sliderMaxPos);

int imageIndex = getCurrentImageIndex();
if (imageIndex > -1)
binding.pageSlider.setValue(Helper.coerceIn(imageIndex, 0, sliderMaxPos));
// Only update slider when user isn't skimming _with_ the slider
if (binding.imagePreviewCenter.getVisibility() != View.VISIBLE) {
int sliderMaxPos = Math.max(1, maxPageNum - 1);
// Next line to avoid setting a max position inferior to current position
binding.pageSlider.setValue(Helper.coerceIn(binding.pageSlider.getValue(), 0, sliderMaxPos));
binding.pageSlider.setValueTo(sliderMaxPos);

int imageIndex = getCurrentImageIndex();
if (imageIndex > -1)
binding.pageSlider.setValue(Helper.coerceIn(imageIndex, 0, sliderMaxPos));
}

if (!Preferences.isReaderChapteredNavigation() || null == chapters || chapters.isEmpty()) {
prevFunctionalButton.setVisibility(isContentFirst ? View.INVISIBLE : View.VISIBLE);
Expand Down

0 comments on commit 2ce290c

Please sign in to comment.