diff --git a/css/style.css b/css/style.css index 06610b8..58fefd4 100644 --- a/css/style.css +++ b/css/style.css @@ -69,6 +69,10 @@ footer { background: #333; } +#feature-list { + scrollbar-width: none; +} + .feature-list-item { padding: 0.5rem; cursor: pointer; diff --git a/scripts/features.js b/scripts/features.js index fe791a5..6eae638 100644 --- a/scripts/features.js +++ b/scripts/features.js @@ -1,5 +1,6 @@ const featureTitles = document.getElementsByClassName('feature-list-item'); const featureDetails = document.getElementsByClassName('feature-detail-container'); +const featureList = document.getElementById('feature-list'); let currentFeature = 0; for (let i = 0; i < featureTitles.length; i++) { @@ -18,6 +19,7 @@ for (let i = 0; i < featureTitles.length; i++) { function updateActiveFeature(i) { const lastCurrentFeature = currentFeature; currentFeature = i; + // console.log(`${lastCurrentFeature} -> ${currentFeature}`); // New current feature featureTitles[currentFeature].className += ' gradient-spin my-gradient'; @@ -30,4 +32,12 @@ function updateActiveFeature(i) { featureTitles[lastCurrentFeature].style = ''; featureDetails[lastCurrentFeature].removeAttribute('id'); + // Update scroll position + const offsetPadding = 20; + if (lastCurrentFeature < currentFeature) { + featureList.scrollLeft = featureTitles[currentFeature].offsetLeft - offsetPadding; + } else { + featureList.scrollLeft = featureTitles[currentFeature].offsetLeft - featureTitles[currentFeature].offsetWidth/2 - offsetPadding; + } + } \ No newline at end of file