Created
April 30, 2022 20:04
-
-
Save SergeyMell/641824c53729c6bbcbd9b070268ab76c to your computer and use it in GitHub Desktop.
Infinite image gallery core js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const container = document.querySelector('.gallery__container'); | |
const prevButton = document.querySelector('.gallery__prev'); | |
const nextButton = document.querySelector('.gallery__next'); | |
prevButton.onclick = () => { | |
const items = document.querySelectorAll('.gallery__item'); | |
container.insertBefore(items[items.length - 1], items[0]); | |
}; | |
nextButton.onclick = () => { | |
const items = document.querySelectorAll('.gallery__item'); | |
container.appendChild(items[0]); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment