2024-09-23 23:57:27 +00:00
|
|
|
const featureCardElems = document.getElementsByClassName('feature-card');
|
|
|
|
const featureCardContainerElem = document.getElementById('feature-card-container');
|
|
|
|
let currentFeatureCard = 1
|
2024-04-23 16:16:44 +00:00
|
|
|
|
2024-09-23 23:57:27 +00:00
|
|
|
for (let i = 0; i < featureCardElems.length; i++) {
|
|
|
|
featureCardElems[i].addEventListener('click', function() {
|
|
|
|
if (i != currentFeatureCard) {
|
|
|
|
updateActiveFeatureCard(i);
|
2024-04-24 13:53:04 +00:00
|
|
|
}
|
2024-04-23 16:16:44 +00:00
|
|
|
}, false)
|
|
|
|
}
|
|
|
|
|
2024-09-23 23:57:27 +00:00
|
|
|
function updateActiveFeatureCard(i) {
|
|
|
|
const lastCurrentFeature = currentFeatureCard;
|
|
|
|
currentFeatureCard = i;
|
|
|
|
console.log(i)
|
2024-04-23 22:34:02 +00:00
|
|
|
|
2024-09-23 23:57:27 +00:00
|
|
|
featureCardElems[i].id = 'active-feature-card';
|
|
|
|
featureCardElems[lastCurrentFeature].id = "";
|
|
|
|
if (lastCurrentFeature < i) {
|
|
|
|
// featureCardContainerElem.scrollLeft = featureCardElems[i].offsetLeft - featureCardElems[i].offsetWidth/2
|
|
|
|
featureCardContainerElem.scrollIntoView
|
2024-04-24 17:10:15 +00:00
|
|
|
} else {
|
2024-09-23 23:57:27 +00:00
|
|
|
featureCardContainerElem.scrollLeft = featureCardElems[i].offsetLeft - featureCardElems[i].offsetWidth
|
2024-06-18 17:17:39 +00:00
|
|
|
}
|
2024-09-23 23:57:27 +00:00
|
|
|
}
|