Skip to content

Instantly share code, notes, and snippets.

@jonchretien
Created October 20, 2016 15:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jonchretien/1df97dbe436ed894f528ab602a19692a to your computer and use it in GitHub Desktop.
Save jonchretien/1df97dbe436ed894f528ab602a19692a to your computer and use it in GitHub Desktop.
let swapHeaderImage = (() => {
const hero = document.querySelector('.hero');
let current = 1;
let next = 2;
function init() {
hero.classList.remove(Array.from(hero.classList).pop());
hero.classList.add(`artist-banner-${current}`);
}
function jump(num) {
hero.classList.remove(Array.from(hero.classList).pop());
hero.classList.add(`artist-banner-${num}`);
current = num;
next = num++;
}
function increment() {
hero.classList.remove(`artist-banner-${current}`);
hero.classList.add(`artist-banner-${next}`);
current = next;
next++;
}
function decrement() {
let previous = current - 1;
hero.classList.remove(`artist-banner-${current}`);
hero.classList.add(`artist-banner-${previous}`);
current = previous;
previous--
}
return {init, jump, increment, decrement};
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment