Skip to content

Commit

Permalink
Fix carousel navigation and add event listener for storage change
Browse files Browse the repository at this point in the history
  • Loading branch information
Arejula11 committed Apr 4, 2024
1 parent f580df8 commit ac0b93f
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion playbeat/src/pages/home.astro
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,26 @@ const Canciones = [
if(leftArrow && rightArrow && carrusel){

for(let i = 0; i < carrusel.length; i++) {
let width = carrusel[i].offsetWidth;

leftArrow[i].addEventListener('click', () => {
let width = carrusel[i].offsetWidth;
carrusel[i].scrollBy({ left: -width, behavior: 'smooth' });
});

rightArrow[i].addEventListener('click', () => {
let width = carrusel[i].offsetWidth;
carrusel[i].scrollBy({ left: width, behavior: 'smooth' });
});
}
}
})
</script>
<script is:inline>
document.addEventListener('astro:after-swap', () => {
window.dispatchEvent(new Event('storageChange'));

});
</script>
</Layout>


Expand Down

0 comments on commit ac0b93f

Please sign in to comment.