From a1d62756b1dae47496aaa53007a9aa4c8fb0c769 Mon Sep 17 00:00:00 2001 From: Eduard Prigoana Date: Wed, 22 Oct 2025 18:03:28 +0300 Subject: [PATCH] fix --- assets/appicon.png | Bin 0 -> 7324 bytes index.html | 2 +- js/app.js | 57 ++++++++++++++++++++++++++++++++++++++------- manifest.json | 6 ++--- styles.css | 5 +++- 5 files changed, 56 insertions(+), 14 deletions(-) create mode 100644 assets/appicon.png diff --git a/assets/appicon.png b/assets/appicon.png new file mode 100644 index 0000000000000000000000000000000000000000..6b2cc5a8f1cb1ad9915665159501b4bafbd63ac8 GIT binary patch literal 7324 zcmeAS@N?(olHy`uVBq!ia0y~yU;#2&7&zE~RK2WrGmv5|4sv&5Sa(k5B}gjW(btiI zVPik{pF~z5pR>RtvY3H^?+6GpPSxg<1`0})xJHx&=ckpFCl;kL1SDqWmFW4ohA5co z8R}W)X6s4hbT1CXru2k8vWnY(WQUFq%V;uum9_x8@lE|Hf~4G;If6}vXklP4sg zhlka8qM@Ln;g_U69Qp^2R2zsGhO--9auD$GF$tCkWJ#ZsyuS26%J&@w3$knHvv>Xc zpMNQ9*Xy$-o{GXZ@8A0eGbH40jq05{ckagByRCf_>VV~Y-N~Dq(~mc^^B-&F7GK86 z@L{ud__`i-|9L*vGvxP!%ES-#1r;yuX?<1$<*nfystThX1ctz9g#tInNVdrOQhBLF)OCGLS z^WI|DXa3I*zj7R~R|O@l(VAqmUw-w~tXT}RzkGXpyYTa~vmgKb{9O3u z#l=jnoJ0Tq{j(^2b!A8O_jfzW-roB0>FMb&@(ID)wrx9h?%cTwU>#)A_*0N!hAtz+ zv((zgk8f^n-nf1Hb3XQ*8^6x|U+zEu*x`2mPUzp)XwVVty!w>POdhO$nEg1d?kCvRHCFf`ZVzj3Q zsyRm+5TH
- Current Track Cover + Current Track Cover
Select a song
diff --git a/js/app.js b/js/app.js index 678bf7b..4ae254d 100644 --- a/js/app.js +++ b/js/app.js @@ -396,6 +396,49 @@ document.addEventListener('DOMContentLoaded', async () => { window.loadHomeFeed = loadHomeFeed; + function positionContextMenu(menu, x, y, preferLeft = false) { + menu.style.display = 'block'; + menu.style.visibility = 'hidden'; + + const menuRect = menu.getBoundingClientRect(); + const viewportWidth = window.innerWidth; + const viewportHeight = window.innerHeight; + + let finalX = x; + let finalY = y; + + if (preferLeft || (x + menuRect.width > viewportWidth)) { + finalX = x - menuRect.width; + if (finalX < 0) { + finalX = Math.min(x, viewportWidth - menuRect.width - 10); + } + } + + if (finalX < 10) { + finalX = 10; + } + + if (finalX + menuRect.width > viewportWidth - 10) { + finalX = viewportWidth - menuRect.width - 10; + } + + if (y + menuRect.height > viewportHeight) { + finalY = Math.max(10, y - menuRect.height); + } + + if (finalY + menuRect.height > viewportHeight - 10) { + finalY = viewportHeight - menuRect.height - 10; + } + + if (finalY < 10) { + finalY = 10; + } + + menu.style.left = `${finalX}px`; + menu.style.top = `${finalY}px`; + menu.style.visibility = 'visible'; + } + function updateLastFMUI() { if (scrobbler.isAuthenticated()) { lastfmStatus.textContent = `Connected as ${scrobbler.username}`; @@ -808,11 +851,11 @@ document.addEventListener('DOMContentLoaded', async () => { function showQueueTrackMenu(e, trackIndex) { const menu = document.getElementById('queue-track-menu'); - menu.style.top = `${e.pageY}px`; - menu.style.left = `${e.pageX}px`; menu.classList.add('show'); menu.dataset.trackIndex = trackIndex; + positionContextMenu(menu, e.pageX, e.pageY, true); + document.addEventListener('click', hideQueueTrackMenu); } @@ -845,9 +888,7 @@ document.addEventListener('DOMContentLoaded', async () => { contextTrack = trackDataStore.get(trackItem); if (contextTrack) { const rect = menuBtn.getBoundingClientRect(); - contextMenu.style.top = `${rect.bottom + 5}px`; - contextMenu.style.left = `${rect.left}px`; - contextMenu.style.display = 'block'; + positionContextMenu(contextMenu, rect.left, rect.bottom + 5, true); } } return; @@ -877,9 +918,7 @@ document.addEventListener('DOMContentLoaded', async () => { contextTrack = trackDataStore.get(trackItem); if (contextTrack) { - contextMenu.style.top = `${e.pageY}px`; - contextMenu.style.left = `${e.pageX}px`; - contextMenu.style.display = 'block'; + positionContextMenu(contextMenu, e.pageX, e.pageY, true); } } }); @@ -1160,4 +1199,4 @@ document.addEventListener('DOMContentLoaded', async () => { e.preventDefault(); deferredPrompt = e; }); -}); +}); \ No newline at end of file diff --git a/manifest.json b/manifest.json index 0a211d4..5453afc 100644 --- a/manifest.json +++ b/manifest.json @@ -9,19 +9,19 @@ "orientation": "portrait-primary", "icons": [ { - "src": "/assets/192.png", + "src": "/assets/appicon.png", "sizes": "192x192", "type": "image/png", "purpose": "any" }, { - "src": "/assets/512.png", + "src": "/assets/appicon.png", "sizes": "512x512", "type": "image/png", "purpose": "any" }, { - "src": "/assets/512.png", + "src": "/assets/appicon.png", "sizes": "512x512", "type": "image/png", "purpose": "maskable" diff --git a/styles.css b/styles.css index 34f2ebd..a90be22 100644 --- a/styles.css +++ b/styles.css @@ -589,7 +589,10 @@ a { z-index: 10; } -.track-item:hover .track-menu-btn, +.track-item:hover .track-menu-btn { + opacity: 1; +} + @media (hover: none) { .track-menu-btn { opacity: 1;