feat(web): zoom du lecteur — contrôles +/−/reset (50–300 %) sur PDF et CBZ
This commit is contained in:
@ -3,6 +3,24 @@ export type ReaderSize = {
|
||||
height: number;
|
||||
};
|
||||
|
||||
export const READER_ZOOM_MIN = 50;
|
||||
export const READER_ZOOM_MAX = 300;
|
||||
export const READER_ZOOM_STEP = 25;
|
||||
export const READER_ZOOM_DEFAULT = 100;
|
||||
|
||||
export function clampReaderZoom(zoom: number) {
|
||||
const steppedZoom = Math.round(zoom / READER_ZOOM_STEP) * READER_ZOOM_STEP;
|
||||
return Math.max(READER_ZOOM_MIN, Math.min(steppedZoom, READER_ZOOM_MAX));
|
||||
}
|
||||
|
||||
export function readerZoomLabel(zoom: number) {
|
||||
return `${clampReaderZoom(zoom)} %`;
|
||||
}
|
||||
|
||||
export function readerZoomFactor(zoom: number) {
|
||||
return clampReaderZoom(zoom) / 100;
|
||||
}
|
||||
|
||||
export function clampReaderPage(page: number, pageCount: number) {
|
||||
const safePageCount = Math.max(1, Math.floor(pageCount));
|
||||
return Math.max(1, Math.min(Math.floor(page), safePageCount));
|
||||
@ -45,6 +63,14 @@ export function orientedContainPageSize(viewport: ReaderSize, page: ReaderSize):
|
||||
};
|
||||
}
|
||||
|
||||
export function zoomReaderSize(size: ReaderSize, zoom: number): ReaderSize {
|
||||
const factor = readerZoomFactor(zoom);
|
||||
return {
|
||||
width: Math.max(1, Math.floor(size.width * factor)),
|
||||
height: Math.max(1, Math.floor(size.height * factor))
|
||||
};
|
||||
}
|
||||
|
||||
export function readableViewportSize(size: ReaderSize): ReaderSize | null {
|
||||
if (size.width < 32 || size.height < 32) return null;
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user