From 4c3638c17ca9c9da9fa7555f049cfaf6cf9fae47 Mon Sep 17 00:00:00 2001 From: rene Date: Wed, 29 Apr 2026 11:54:38 +0200 Subject: [PATCH] =?UTF-8?q?Fix:=20Tages=C3=BCbung-Scroll=20via=20=5Fscroll?= =?UTF-8?q?Target=20nach=20exercises-Load=20statt=20fixem=20Timeout=20?= =?UTF-8?q?=E2=80=94=20SW=20by-v494,=20APP=5FVER=20471?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/static/js/app.js | 2 +- backend/static/js/pages/uebungen.js | 25 +++++++++++++++++-------- backend/static/sw.js | 2 +- 3 files changed, 19 insertions(+), 10 deletions(-) diff --git a/backend/static/js/app.js b/backend/static/js/app.js index 5924331..207f87b 100644 --- a/backend/static/js/app.js +++ b/backend/static/js/app.js @@ -3,7 +3,7 @@ Router, State-Management, Navigation, Initialisierung. ============================================================ */ -const APP_VER = '470'; // ← bei jedem Deploy mit Frontend-Änderungen erhöhen +const APP_VER = '471'; // ← bei jedem Deploy mit Frontend-Änderungen erhöhen const App = (() => { diff --git a/backend/static/js/pages/uebungen.js b/backend/static/js/pages/uebungen.js index fa7ff50..921386a 100644 --- a/backend/static/js/pages/uebungen.js +++ b/backend/static/js/pages/uebungen.js @@ -38,6 +38,7 @@ window.Page_uebungen = (() => { let _badgesData = null; // cached badges from /api/achievements let _exercisesByTab = {}; // aus API geladen let _exercisesLoaded = false; + let _scrollTarget = null; // { exercise_id, name } — nach _renderContent() scrollen // ---------------------------------------------------------- // DATEN @@ -485,14 +486,7 @@ window.Page_uebungen = (() => { } if (params.exercise_id || params.name) { - setTimeout(() => { - // Erst per exercise_id suchen (zuverlässig), dann per Name als Fallback - const card = (params.exercise_id - ? _container.querySelector(`[data-exercise-id="${CSS.escape(params.exercise_id)}"]`) - : null) - || _container.querySelector(`[data-exercise-name="${CSS.escape(params.name || '')}"]`); - if (card) card.scrollIntoView({ behavior: 'smooth', block: 'center' }); - }, 700); + _scrollTarget = { exercise_id: params.exercise_id || '', name: params.name || '' }; } // Progress vom Server laden @@ -971,6 +965,21 @@ window.Page_uebungen = (() => { _bindLogButtons(); _bindNotizButtons(); if (_activeTab === 'ki-trainer') _loadKiTrainerFeedback(); + _tryScrollToTarget(); + } + + function _tryScrollToTarget() { + if (!_scrollTarget) return; + const t = _scrollTarget; + requestAnimationFrame(() => { + const card = (t.exercise_id + ? _container.querySelector('[data-exercise-id="' + CSS.escape(t.exercise_id) + '"]') + : null) || _container.querySelector('[data-exercise-name="' + CSS.escape(t.name) + '"]'); + if (card) { + card.scrollIntoView({ behavior: 'smooth', block: 'center' }); + _scrollTarget = null; + } + }); } // ---------------------------------------------------------- diff --git a/backend/static/sw.js b/backend/static/sw.js index 204f6a0..5e0f9ee 100644 --- a/backend/static/sw.js +++ b/backend/static/sw.js @@ -3,7 +3,7 @@ Offline-Cache + Push Notifications + Tile-Cache ============================================================ */ -const CACHE_VERSION = 'by-v493'; +const CACHE_VERSION = 'by-v494'; const CACHE_STATIC = `${CACHE_VERSION}-static`; const CACHE_TILES = 'ban-yaro-tiles-v1'; // bleibt über SW-Updates erhalten