2024-04-23 22:52:54 +00:00
|
|
|
const featureTitles = document.getElementsByClassName('feature-list-item');
|
|
|
|
const featureDetails = document.getElementsByClassName('feature-detail-container');
|
2024-04-24 17:10:15 +00:00
|
|
|
const featureList = document.getElementById('feature-list');
|
2024-04-23 22:52:54 +00:00
|
|
|
let currentFeature = 0;
|
2024-04-23 16:16:44 +00:00
|
|
|
|
|
|
|
for (let i = 0; i < featureTitles.length; i++) {
|
|
|
|
featureTitles[i].addEventListener('click', function () {
|
2024-04-24 13:53:04 +00:00
|
|
|
if (i != currentFeature) {
|
|
|
|
updateActiveFeature(i);
|
|
|
|
}
|
2024-04-23 16:16:44 +00:00
|
|
|
}, false)
|
2024-04-24 13:53:04 +00:00
|
|
|
|
|
|
|
// We need to remove the gradient so that linearBackground is hidden
|
2024-04-23 17:14:44 +00:00
|
|
|
if (featureTitles[i].id != 'active-feature-item') {
|
2024-04-24 14:52:30 +00:00
|
|
|
featureTitles[i].className = 'col feature-list-item rounded-3 m-0';
|
2024-04-23 17:14:44 +00:00
|
|
|
}
|
2024-04-23 16:16:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function updateActiveFeature(i) {
|
2024-04-23 22:52:54 +00:00
|
|
|
const lastCurrentFeature = currentFeature;
|
|
|
|
currentFeature = i;
|
2024-04-24 17:10:15 +00:00
|
|
|
// console.log(`${lastCurrentFeature} -> ${currentFeature}`);
|
2024-04-23 16:16:44 +00:00
|
|
|
|
2024-04-23 22:52:54 +00:00
|
|
|
// New current feature
|
|
|
|
featureTitles[currentFeature].className += ' gradient-spin my-gradient';
|
|
|
|
featureTitles[currentFeature].id = 'active-feature-item';
|
|
|
|
featureDetails[currentFeature].id = 'active-feature-detail'
|
2024-04-23 22:34:02 +00:00
|
|
|
|
2024-04-23 22:52:54 +00:00
|
|
|
// Reset previous current feature
|
|
|
|
featureTitles[lastCurrentFeature].removeAttribute('id');
|
2024-04-24 14:52:30 +00:00
|
|
|
featureTitles[lastCurrentFeature].className = 'col feature-list-item rounded-3 m-0';
|
2024-04-23 22:52:54 +00:00
|
|
|
featureTitles[lastCurrentFeature].style = '';
|
|
|
|
featureDetails[lastCurrentFeature].removeAttribute('id');
|
2024-04-23 22:34:02 +00:00
|
|
|
|
2024-04-24 17:10:15 +00:00
|
|
|
// 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;
|
|
|
|
}
|
|
|
|
|
2024-04-23 16:16:44 +00:00
|
|
|
}
|