Created
October 20, 2016 15:44
-
-
Save jonchretien/1df97dbe436ed894f528ab602a19692a to your computer and use it in GitHub Desktop.
This file contains 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
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