2024-09-24 23:16:37 +00:00
|
|
|
const featureContainerElems = document.getElementsByClassName('feature-container');
|
2024-09-24 15:46:13 +00:00
|
|
|
let currentFeature = 1
|
2024-04-23 16:16:44 +00:00
|
|
|
|
2024-09-24 23:16:37 +00:00
|
|
|
for (let i = 0; i < featureContainerElems.length; i++) {
|
|
|
|
featureContainerElems[i].addEventListener('click', function() {
|
2024-09-24 15:46:13 +00:00
|
|
|
if (i != currentFeature) {
|
|
|
|
updateActiveFeature(i);
|
|
|
|
}
|
|
|
|
})
|
2024-09-24 23:16:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
document.addEventListener('keyup', keyControl);
|
|
|
|
|
|
|
|
function keyControl(e) {
|
|
|
|
if (e.code == 'ArrowRight') {
|
|
|
|
if (currentFeature < featureContainerElems.length-2) {
|
|
|
|
updateActiveFeature(currentFeature + 1);
|
|
|
|
} else {
|
|
|
|
updateActiveFeature(1);
|
2024-04-24 13:53:04 +00:00
|
|
|
}
|
2024-09-24 23:16:37 +00:00
|
|
|
}
|
|
|
|
if (e.code == 'ArrowLeft') {
|
|
|
|
if (currentFeature > 1) {
|
|
|
|
updateActiveFeature(currentFeature - 1);
|
|
|
|
} else {
|
|
|
|
updateActiveFeature(featureContainerElems.length-2);
|
|
|
|
}
|
|
|
|
}
|
2024-04-23 16:16:44 +00:00
|
|
|
}
|
|
|
|
|
2024-09-24 15:46:13 +00:00
|
|
|
function updateActiveFeature(i) {
|
|
|
|
const lastCurrentFeature = currentFeature;
|
|
|
|
currentFeature = i;
|
|
|
|
|
2024-09-24 23:16:37 +00:00
|
|
|
featureContainerElems[i].id = 'active-feature';
|
|
|
|
featureContainerElems[i].scrollIntoView({block: 'start', inline: 'center'});
|
|
|
|
featureContainerElems[lastCurrentFeature].id = ''
|
2024-09-23 23:57:27 +00:00
|
|
|
}
|