Apply auto vertical progress bar for BOTTOM position only
In case "auto vertical position" is not "OFF" but the main position is not "BOTTOM", the auto mode still should be considered to be "OFF"
This commit is contained in:
@@ -10,6 +10,8 @@ import { ForwardRefExoticComponent, MemoExoticComponent, RefAttributes } from 'r
|
||||
import {
|
||||
IReaderSettings,
|
||||
IReaderSettingsWithDefaultFlag,
|
||||
ProgressBarPosition,
|
||||
ProgressBarPositionAutoVertical,
|
||||
ReaderPagerProps,
|
||||
ReaderPageScaleMode,
|
||||
ReadingMode,
|
||||
@@ -56,3 +58,22 @@ export const getPagerForReadingMode = (
|
||||
throw new Error(`Unexpected "ReadingMode" (${readingMode})`);
|
||||
}
|
||||
};
|
||||
|
||||
export const getProgressBarPosition = (
|
||||
progressBarPosition: ProgressBarPosition,
|
||||
progressBarPositionAutoVertical: ProgressBarPositionAutoVertical,
|
||||
topOffset: number = 0,
|
||||
bottomOffset: number = 0,
|
||||
): ProgressBarPosition => {
|
||||
const isAutoVerticalEnabled =
|
||||
progressBarPositionAutoVertical !== ProgressBarPositionAutoVertical.OFF &&
|
||||
progressBarPosition === ProgressBarPosition.BOTTOM;
|
||||
const isVerticalSpaceLarger = window.innerHeight - topOffset - bottomOffset > window.innerWidth;
|
||||
|
||||
const shouldUseVerticalPosition = isAutoVerticalEnabled && isVerticalSpaceLarger;
|
||||
if (shouldUseVerticalPosition) {
|
||||
return progressBarPositionAutoVertical as unknown as ProgressBarPosition;
|
||||
}
|
||||
|
||||
return progressBarPosition;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user