sequoia00 3 nedēļas atpakaļ
vecāks
revīzija
a2f5fca2aa
1 mainītis faili ar 15 papildinājumiem un 1 dzēšanām
  1. 15 1
      static/js/app.js

+ 15 - 1
static/js/app.js

@@ -161,6 +161,15 @@ function showView(name) {
   savePlaybackState();
 }
 
+function scrollToPageTop() {
+  requestAnimationFrame(() => {
+    const scroller = document.scrollingElement || document.documentElement;
+    scroller.scrollTop = 0;
+    scroller.scrollLeft = 0;
+    window.scrollTo(0, 0);
+  });
+}
+
 function coverLabel(name) {
   return name.length > 12 ? `${name.slice(0, 12)}...` : name;
 }
@@ -276,6 +285,7 @@ function renderAlbumDetail(path) {
   state.activeAlbumPath = path;
   setCurrentFolder(path);
   showView("detail");
+  scrollToPageTop();
 
   document.getElementById("detailTitle").textContent = album.name;
   document.getElementById("detailMeta").textContent = `${album.path} · ${album.tracks.length} 首歌曲`;
@@ -652,7 +662,10 @@ progressBar.addEventListener("input", () => {
   audio.currentTime = (Number(progressBar.value) / 100) * audio.duration;
 });
 
-document.getElementById("backHomeBtn").onclick = () => showView("home");
+document.getElementById("backHomeBtn").onclick = () => {
+  showView("home");
+  scrollToPageTop();
+};
 document.getElementById("saveQueueBtn").onclick = () => renderQueue();
 document.getElementById("playModeBtn").onclick = () => {
   const modes = ["shuffle", "one", "list", "once"];
@@ -667,6 +680,7 @@ document.getElementById("closeAlbumMenuBtn").onclick = () => toggleAlbumMenu(fal
 document.getElementById("albumMenuHomeBtn").onclick = () => {
   toggleAlbumMenu(false);
   showView("home");
+  scrollToPageTop();
 };
 document.getElementById("albumMenuOverlay").onclick = (event) => {
   if (event.target.id === "albumMenuOverlay") toggleAlbumMenu(false);