Spaces:
Running
Running
update ml links
Browse files- math-ds-complete/app.js +15 -11
math-ds-complete/app.js
CHANGED
|
@@ -114,17 +114,18 @@ function initNavigation() {
|
|
| 114 |
link.addEventListener('click', (e) => {
|
| 115 |
e.preventDefault();
|
| 116 |
const topicId = link.getAttribute('data-topic');
|
| 117 |
-
|
|
|
|
| 118 |
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
});
|
| 129 |
});
|
| 130 |
}
|
|
@@ -137,7 +138,10 @@ function updateActiveLink(topicId) {
|
|
| 137 |
if (activeLink) {
|
| 138 |
activeLink.classList.add('active');
|
| 139 |
}
|
| 140 |
-
currentTopic
|
|
|
|
|
|
|
|
|
|
| 141 |
}
|
| 142 |
|
| 143 |
// ===== SCROLL OBSERVER =====
|
|
|
|
| 114 |
link.addEventListener('click', (e) => {
|
| 115 |
e.preventDefault();
|
| 116 |
const topicId = link.getAttribute('data-topic');
|
| 117 |
+
// Handle both regular topics and ML topics
|
| 118 |
+
const target = document.getElementById(topicId.startsWith('ml-') ? topicId : `topic-${topicId}`);
|
| 119 |
|
| 120 |
+
if (target) {
|
| 121 |
+
target.scrollIntoView({ behavior: 'smooth', block: 'start' });
|
| 122 |
+
updateActiveLink(topicId);
|
| 123 |
+
|
| 124 |
+
// Close mobile menu if open
|
| 125 |
+
if (window.innerWidth <= 1024) {
|
| 126 |
+
sidebar.classList.remove('active');
|
| 127 |
+
}
|
| 128 |
+
}
|
| 129 |
});
|
| 130 |
});
|
| 131 |
}
|
|
|
|
| 138 |
if (activeLink) {
|
| 139 |
activeLink.classList.add('active');
|
| 140 |
}
|
| 141 |
+
// Only update currentTopic if it's a number
|
| 142 |
+
if (!topicId.startsWith('ml-')) {
|
| 143 |
+
currentTopic = parseInt(topicId);
|
| 144 |
+
}
|
| 145 |
}
|
| 146 |
|
| 147 |
// ===== SCROLL OBSERVER =====
|