mirror of
https://github.com/xiaoqidun/ofdgo.git
synced 2026-10-29 16:59:27 +08:00
1 parent
3227134bfc
commit
3f774056da
1 file changed
+18
-2
+18
-2
@@ -117,6 +117,7 @@ const state = {
|
|||||||
fontSyncing: false,
|
fontSyncing: false,
|
||||||
doc: null,
|
doc: null,
|
||||||
pageIndex: 0,
|
pageIndex: 0,
|
||||||
|
pageNavigation: null,
|
||||||
scale: 1,
|
scale: 1,
|
||||||
rotation: 0,
|
rotation: 0,
|
||||||
panMode: false,
|
panMode: false,
|
||||||
@@ -5632,6 +5633,7 @@ async function renderPage(index, options = {}) {
|
|||||||
if (index < 0 || index >= pageCount) {
|
if (index < 0 || index >= pageCount) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
if (options.navigation !== state.pageNavigation) state.pageNavigation = null;
|
||||||
if (!options.keepBusy && index !== state.pageIndex) {
|
if (!options.keepBusy && index !== state.pageIndex) {
|
||||||
if (!await canvasEditor.commitNudge() || !await canvasEditor.commitText() || !await canvasEditor.commitCrop() || openSeq !== state.openSeq) return null;
|
if (!await canvasEditor.commitNudge() || !await canvasEditor.commitText() || !await canvasEditor.commitCrop() || openSeq !== state.openSeq) return null;
|
||||||
}
|
}
|
||||||
@@ -8980,6 +8982,7 @@ function renderPageFlow() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function resetPageFlow(keepCache = false) {
|
function resetPageFlow(keepCache = false) {
|
||||||
|
state.pageNavigation = null;
|
||||||
if (!keepCache) {
|
if (!keepCache) {
|
||||||
state.pageCache.clear();
|
state.pageCache.clear();
|
||||||
releasePageResources();
|
releasePageResources();
|
||||||
@@ -9613,9 +9616,11 @@ async function navigateDestination(dest, openAction) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const seq = state.openSeq, scale = state.scale;
|
const seq = state.openSeq, scale = state.scale;
|
||||||
await renderPage(index, { fit: false, scroll: false, openAction });
|
const navigation = state.pageNavigation = { openSeq: seq, index };
|
||||||
|
try {
|
||||||
|
await renderPage(index, { fit: false, scroll: false, openAction, navigation });
|
||||||
if (openAction && state.openActionTask !== openAction) return false;
|
if (openAction && state.openActionTask !== openAction) return false;
|
||||||
if (seq !== state.openSeq || state.pageIndex !== index) return;
|
if (seq !== state.openSeq || state.pageIndex !== index || state.pageNavigation !== navigation) return;
|
||||||
const page = state.doc.pages[index], size = pageViewSize(page), space = pageSpace();
|
const page = state.doc.pages[index], size = pageViewSize(page), space = pageSpace();
|
||||||
const width = el.viewerPanel.clientWidth - space * 2, height = el.viewerPanel.clientHeight - space * 2;
|
const width = el.viewerPanel.clientWidth - space * 2, height = el.viewerPanel.clientHeight - space * 2;
|
||||||
let left = dest.omitLeft ? 0 : (dest.left ?? 0);
|
let left = dest.omitLeft ? 0 : (dest.left ?? 0);
|
||||||
@@ -9647,6 +9652,12 @@ async function navigateDestination(dest, openAction) {
|
|||||||
const node = pageShell(index), shell = node.getBoundingClientRect(), viewer = el.viewerPanel.getBoundingClientRect();
|
const node = pageShell(index), shell = node.getBoundingClientRect(), viewer = el.viewerPanel.getBoundingClientRect();
|
||||||
el.viewerPanel.scrollLeft += shell.left + (node.clientLeft || 0) - viewer.left - (el.viewerPanel.clientLeft || 0) + point.x * MM_TO_PX * state.scale;
|
el.viewerPanel.scrollLeft += shell.left + (node.clientLeft || 0) - viewer.left - (el.viewerPanel.clientLeft || 0) + point.x * MM_TO_PX * state.scale;
|
||||||
scrollViewerBy(shell.top + (node.clientTop || 0) - viewer.top - (el.viewerPanel.clientTop || 0) + point.y * MM_TO_PX * state.scale);
|
scrollViewerBy(shell.top + (node.clientTop || 0) - viewer.top - (el.viewerPanel.clientTop || 0) + point.y * MM_TO_PX * state.scale);
|
||||||
|
} finally {
|
||||||
|
if (state.pageNavigation === navigation) {
|
||||||
|
if (seq !== state.openSeq || index !== state.pageIndex) state.pageNavigation = null;
|
||||||
|
else Object.assign(navigation, { top: state.pageWindow ? pageWindowTop(state.pageWindow) : el.viewerPanel.scrollTop, left: el.viewerPanel.scrollLeft });
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function createTextLayer(text) {
|
function createTextLayer(text) {
|
||||||
@@ -10006,6 +10017,11 @@ function schedulePageSync() {
|
|||||||
function syncCurrentPageFromScroll() {
|
function syncCurrentPageFromScroll() {
|
||||||
if (state.openActionTask?.navigating) return;
|
if (state.openActionTask?.navigating) return;
|
||||||
syncPageWindow(state.pageWindow);
|
syncPageWindow(state.pageWindow);
|
||||||
|
const navigation = state.pageNavigation;
|
||||||
|
const top = state.pageWindow ? pageWindowTop(state.pageWindow) : el.viewerPanel.scrollTop;
|
||||||
|
if (navigation?.openSeq === state.openSeq && navigation.index === state.pageIndex
|
||||||
|
&& (navigation.top === undefined || Math.abs(navigation.top - top) < 1 && Math.abs(navigation.left - el.viewerPanel.scrollLeft) < 1)) return;
|
||||||
|
state.pageNavigation = null;
|
||||||
if (canvasEditor.input || canvasEditor.drag || canvasEditor.crop) return;
|
if (canvasEditor.input || canvasEditor.drag || canvasEditor.crop) return;
|
||||||
const shell = pageShellFromView();
|
const shell = pageShellFromView();
|
||||||
if (!shell) {
|
if (!shell) {
|
||||||
|
|||||||
Reference in new issue
Block a user