aboutsummaryrefslogtreecommitdiffstats
path: root/frontend-vanilla/src
diff options
context:
space:
mode:
Diffstat (limited to 'frontend-vanilla/src')
-rw-r--r--frontend-vanilla/src/main.ts24
-rw-r--r--frontend-vanilla/src/style.css4
2 files changed, 15 insertions, 13 deletions
diff --git a/frontend-vanilla/src/main.ts b/frontend-vanilla/src/main.ts
index 2be9354..e3d3a71 100644
--- a/frontend-vanilla/src/main.ts
+++ b/frontend-vanilla/src/main.ts
@@ -340,18 +340,20 @@ export function renderItems() {
function checkReadItems(scrollRoot: HTMLElement) {
const containerRect = scrollRoot.getBoundingClientRect();
- store.items.forEach((item) => {
- if (item.read) return;
-
- const el = document.querySelector(`.feed-item[data-id="${item._id}"]`);
- if (el) {
- const rect = el.getBoundingClientRect();
- // Mark as read if the bottom of the item is above the top of the container
- if (rect.bottom < containerRect.top) {
- updateItem(item._id, { read: true });
- }
+ // Batch DOM query: select all feed items at once instead of O(n) individual
+ // querySelector calls with attribute selectors per scroll tick.
+ const allItems = scrollRoot.querySelectorAll('.feed-item');
+ for (const el of allItems) {
+ const id = parseInt(el.getAttribute('data-id')!);
+ const item = store.items.find(i => i._id === id);
+ if (!item || item.read) continue;
+
+ const rect = el.getBoundingClientRect();
+ // Mark as read if the bottom of the item is above the top of the container
+ if (rect.bottom < containerRect.top) {
+ updateItem(item._id, { read: true });
}
- });
+ }
}
// Polling fallback for infinite scroll (matches V1 behavior)
diff --git a/frontend-vanilla/src/style.css b/frontend-vanilla/src/style.css
index 0f7b909..fd51eff 100644
--- a/frontend-vanilla/src/style.css
+++ b/frontend-vanilla/src/style.css
@@ -163,7 +163,7 @@ html {
padding: 0.3rem 0.8rem;
margin: 0.1rem 0;
border-radius: 8px;
- transition: all 0.2s ease;
+ transition: background-color 0.2s ease, color 0.2s ease, opacity 0.2s ease, transform 0.2s ease;
font-weight: 500;
font-size: 0.85rem;
/* Explicitly smaller sidebar links */
@@ -703,7 +703,7 @@ button,
font-family: var(--font-heading);
background-color: var(--bg-color);
cursor: pointer;
- transition: all 0.2s;
+ transition: background-color 0.2s, color 0.2s, border-color 0.2s;
color: var(--text-color);
text-decoration: none;
display: inline-block;