mirror of
https://github.com/RetroDECK/RetroDECK-Website.git
synced 2024-11-27 17:15:38 +00:00
49 lines
1.6 KiB
JavaScript
49 lines
1.6 KiB
JavaScript
// const featureContainerElems = document.getElementsByClassName('feature-container');
|
|
// let currentFeature = 1
|
|
|
|
// for (let i = 0; i < featureContainerElems.length; i++) {
|
|
// featureContainerElems[i].addEventListener('click', function() {
|
|
// if (i != currentFeature) {
|
|
// updateActiveFeature(i);
|
|
// }
|
|
// })
|
|
// }
|
|
|
|
// document.addEventListener('keyup', keyControl);
|
|
|
|
// function keyControl(e) {
|
|
// if (e.code == 'ArrowRight') {
|
|
// if (currentFeature < featureContainerElems.length-2) {
|
|
// updateActiveFeature(currentFeature + 1);
|
|
// } else {
|
|
// updateActiveFeature(1);
|
|
// }
|
|
// }
|
|
// if (e.code == 'ArrowLeft') {
|
|
// if (currentFeature > 1) {
|
|
// updateActiveFeature(currentFeature - 1);
|
|
// } else {
|
|
// updateActiveFeature(featureContainerElems.length-2);
|
|
// }
|
|
// }
|
|
// }
|
|
|
|
// function updateActiveFeature(i) {
|
|
// const lastCurrentFeature = currentFeature;
|
|
// currentFeature = i;
|
|
|
|
// featureContainerElems[i].id = 'active-feature';
|
|
// featureContainerElems[i].scrollIntoView({block: 'start', inline: 'center'});
|
|
// featureContainerElems[lastCurrentFeature].id = ''
|
|
// }
|
|
|
|
|
|
document.addEventListener('keyup', function(e) {
|
|
if (e.code == 'ArrowRight') {
|
|
document.getElementById('carousel-next').click();
|
|
document.getElementById('features').scrollIntoView({block: 'center'});
|
|
} else if (e.code == 'ArrowLeft') {
|
|
document.getElementById('carousel-prev').click();
|
|
document.getElementById('features').scrollIntoView({block: 'center'});
|
|
}
|
|
}); |