mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-10 02:05:37 +02:00
Move the zoomIn/zoomOut functionality into BaseViewer
(PR 14038 follow-up)
Given the simplicity of this functionality, we can move it from the default viewer and into the `BaseViewer` class instead. This way, it's possible to support more scripting functionality in the standalone viewer components; please see PR 14038. Please note that I purposely went with `increaseScale`/`decreaseScale`-method names, rather than using "zoom", to better match the existing `currentScale`/`currentScaleValue` getters/setters that's being used in the `BaseViewer` class.
This commit is contained in:
parent
83d3bb43f4
commit
d9f9fa4f1c
4 changed files with 39 additions and 21 deletions
23
web/app.js
23
web/app.js
|
@ -26,8 +26,6 @@ import {
|
|||
isValidRotation,
|
||||
isValidScrollMode,
|
||||
isValidSpreadMode,
|
||||
MAX_SCALE,
|
||||
MIN_SCALE,
|
||||
noContextMenuHandler,
|
||||
normalizeWheelEventDirection,
|
||||
parseQueryString,
|
||||
|
@ -81,7 +79,6 @@ import { SecondaryToolbar } from "./secondary_toolbar.js";
|
|||
import { Toolbar } from "./toolbar.js";
|
||||
import { ViewHistory } from "./view_history.js";
|
||||
|
||||
const DEFAULT_SCALE_DELTA = 1.1;
|
||||
const DISABLE_AUTO_FETCH_LOADING_BAR_TIMEOUT = 5000; // ms
|
||||
const FORCE_PAGES_LOADED_TIMEOUT = 10000; // ms
|
||||
const WHEEL_ZOOM_DISABLED_TIMEOUT = 1000; // ms
|
||||
|
@ -637,30 +634,18 @@ const PDFViewerApplication = {
|
|||
return this._initializedCapability.promise;
|
||||
},
|
||||
|
||||
zoomIn(ticks) {
|
||||
zoomIn(steps) {
|
||||
if (this.pdfViewer.isInPresentationMode) {
|
||||
return;
|
||||
}
|
||||
let newScale = this.pdfViewer.currentScale;
|
||||
do {
|
||||
newScale = (newScale * DEFAULT_SCALE_DELTA).toFixed(2);
|
||||
newScale = Math.ceil(newScale * 10) / 10;
|
||||
newScale = Math.min(MAX_SCALE, newScale);
|
||||
} while (--ticks > 0 && newScale < MAX_SCALE);
|
||||
this.pdfViewer.currentScaleValue = newScale;
|
||||
this.pdfViewer.increaseScale(steps);
|
||||
},
|
||||
|
||||
zoomOut(ticks) {
|
||||
zoomOut(steps) {
|
||||
if (this.pdfViewer.isInPresentationMode) {
|
||||
return;
|
||||
}
|
||||
let newScale = this.pdfViewer.currentScale;
|
||||
do {
|
||||
newScale = (newScale / DEFAULT_SCALE_DELTA).toFixed(2);
|
||||
newScale = Math.floor(newScale * 10) / 10;
|
||||
newScale = Math.max(MIN_SCALE, newScale);
|
||||
} while (--ticks > 0 && newScale > MIN_SCALE);
|
||||
this.pdfViewer.currentScaleValue = newScale;
|
||||
this.pdfViewer.decreaseScale(steps);
|
||||
},
|
||||
|
||||
zoomReset() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue