diff --git a/dev/editviewer.py b/dev/editviewer.py index f9d469027..1e521518a 100644 --- a/dev/editviewer.py +++ b/dev/editviewer.py @@ -14,6 +14,7 @@ .replace('''''', '''\n ''') .replace('''''', '''''') .replace('''''', '''''') + .replace('''
''', '''
''') .replace('''
''', '''''') ) diff --git a/viewer/components/gui.ts b/viewer/components/gui.ts index f9b6ed9db..5b982a2b7 100644 --- a/viewer/components/gui.ts +++ b/viewer/components/gui.ts @@ -8,7 +8,19 @@ import type { PDFViewerApplicationType } from './interface.js' declare const PDFViewerApplication: PDFViewerApplicationType -let hideToolbar: number | undefined +let hideToolbarTimeout: number | undefined +function hideToolbar(params: Awaited>) { + if (typeof PDFViewerApplication === 'undefined') { + return + } + if (hideToolbarTimeout === undefined && !PDFViewerApplication.findBar.opened && !PDFViewerApplication.pdfSidebar.isOpen && !PDFViewerApplication.secondaryToolbar.isOpen) { + hideToolbarTimeout = setTimeout(() => { + const toolbarDom = document.getElementsByClassName('toolbar')[0] + toolbarDom.classList.add('hide') + hideToolbarTimeout = undefined + }, params.toolbar * 1000) + } +} export async function patchViewerUI() { if (utils.isEmbedded()) { // Cannot simply remove this element, as pdf.js indeed require it to @@ -18,38 +30,34 @@ export async function patchViewerUI() { const params = await utils.getParams() + if (params.toolbar === 0) { + document.getElementsByClassName('toolbar')[0]?.classList.remove('hide') + document.getElementById('viewerContainer')!.style.top = '32px' + } + + document.getElementById('outerContainer')!.onmouseleave = () => { + if (params.toolbar !== 0) { + hideToolbar(params) + } + } + document.getElementById('outerContainer')!.onmousemove = (e) => { if (params.toolbar === 0) { return } if (e.clientY <= 64) { - if (hideToolbar) { - clearTimeout(hideToolbar) - hideToolbar = undefined + if (hideToolbarTimeout) { + clearTimeout(hideToolbarTimeout) + hideToolbarTimeout = undefined } showToolbar() } else { - if (typeof PDFViewerApplication === 'undefined') { - return - } - if (hideToolbar === undefined && !PDFViewerApplication.findBar.opened && !PDFViewerApplication.pdfSidebar.isOpen && !PDFViewerApplication.secondaryToolbar.isOpen) { - hideToolbar = setTimeout(() => { - const toolbarDom = document.getElementsByClassName('toolbar')[0] - toolbarDom.classList.add('hide') - const containerDom = document.getElementById('viewerContainer')! - containerDom.classList.add('topped') - hideToolbar = undefined - }, params.toolbar * 1000) - } + hideToolbar(params) } } document.getElementById('sidebarResizer')?.classList.add('hidden') document.getElementById('firstPage')?.previousElementSibling?.classList.add('visibleLargeView') - if (params.toolbar !== 0) { - document.getElementsByClassName('toolbar')[0]?.classList.add('hide') - document.getElementById('viewerContainer')!.classList.add('topped') - } const template = document.createElement('template') template.innerHTML = @@ -241,6 +249,4 @@ export function repositionAnnotation() { function showToolbar() { const toolbarDom = document.getElementsByClassName('toolbar')[0] toolbarDom.classList.remove('hide') - const containerDom = document.getElementById('viewerContainer')! - containerDom.classList.remove('topped') } diff --git a/viewer/latexworkshop.css b/viewer/latexworkshop.css index 1fc491f72..99512fb49 100644 --- a/viewer/latexworkshop.css +++ b/viewer/latexworkshop.css @@ -143,11 +143,7 @@ html[dir='rtl'] .findbar { } #viewerContainer { - transition: all 0.2s cubic-bezier(.23,.96,.57,.99) !important; -} - -#viewerContainer.topped { - top: 0 !important; + top: 0; } #pageNumber { diff --git a/viewer/viewer.html b/viewer/viewer.html index 48b286276..10e634932 100644 --- a/viewer/viewer.html +++ b/viewer/viewer.html @@ -84,7 +84,7 @@
-
+