From c5e0e2dcfa66d15056feaab7e1e1155ee50a8da4 Mon Sep 17 00:00:00 2001 From: Antigravity Date: Mon, 5 Oct 2026 13:02:37 +0300 Subject: [PATCH] fix(reader): mount app volume in docker-compose, move popup to body root and add smooth scroll tracking --- app/static/index.html | 50 +++++++++++++++++++++---------------------- app/static/js/app.js | 32 +++++++++++++++++++++++++-- docker-compose.yml | 1 + 3 files changed, 56 insertions(+), 27 deletions(-) diff --git a/app/static/index.html b/app/static/index.html index b7a8fe4..5201876 100644 --- a/app/static/index.html +++ b/app/static/index.html @@ -5,7 +5,7 @@ Notes — Персональный тренажер и словарь английского языка - + @@ -581,29 +581,6 @@ - - - @@ -919,9 +896,32 @@ + + + - + diff --git a/app/static/js/app.js b/app/static/js/app.js index 5a552a8..f458e91 100644 --- a/app/static/js/app.js +++ b/app/static/js/app.js @@ -2133,8 +2133,8 @@ document.addEventListener('DOMContentLoaded', () => { let top = rect.bottom + 8; // If bottom overflows viewport, flip above the word if (top + popupHeight > viewportHeight - 12) { - if (rect.top - popupHeight - 8 >= 12 || rect.top > viewportHeight / 2) { - top = Math.max(12, rect.top - popupHeight - 8); + if (rect.top - popupHeight - 8 >= 65 || rect.top > viewportHeight / 2) { + top = Math.max(65, rect.top - popupHeight - 8); } } @@ -2206,6 +2206,34 @@ document.addEventListener('DOMContentLoaded', () => { } }); + function updatePopupPositionOnScroll() { + if (!readerWordPopup || readerWordPopup.classList.contains('hidden')) return; + if (!popupCurrentData || !popupCurrentData.targetElement || !popupCurrentData.targetElement.isConnected) { + readerWordPopup.classList.add('hidden'); + return; + } + const rect = popupCurrentData.targetElement.getBoundingClientRect(); + const headerOffset = 65; // reader toolbar sticky height + if (rect.bottom < headerOffset || rect.top > window.innerHeight) { + readerWordPopup.classList.add('hidden'); + return; + } + positionWordPopup(popupCurrentData.targetElement); + } + + let popupScrollRaf = null; + function schedulePopupUpdate() { + if (!readerWordPopup || readerWordPopup.classList.contains('hidden')) return; + if (popupScrollRaf) return; + popupScrollRaf = requestAnimationFrame(() => { + popupScrollRaf = null; + updatePopupPositionOnScroll(); + }); + } + + window.addEventListener('scroll', schedulePopupUpdate, { passive: true, capture: true }); + window.addEventListener('resize', schedulePopupUpdate, { passive: true }); + if (popupSaveBtn) { popupSaveBtn.addEventListener('click', async () => { if (!popupCurrentData) return; diff --git a/docker-compose.yml b/docker-compose.yml index cd96840..21b9e0a 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -7,6 +7,7 @@ services: - "127.0.0.1:8002:8002" volumes: - ./data:/app/data + - ./app:/app/app environment: - HOST=0.0.0.0 - PORT=8002