Last active
August 29, 2019 03:56
-
-
Save AsherFoster/74abafa6944889000f8fdca8a0ce1034 to your computer and use it in GitHub Desktop.
Fading gallery script
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
(function () { | |
const items = document.getElementsByClassName('gallery-fade-item'); | |
let active = 0; | |
if(!items || !items.length) return; | |
// Don't animate in the editor | |
if(document.body.classList.contains('compose-mode')) { | |
return [].slice.call(items).forEach(i => setItem(i, 1)); | |
} | |
function setItem(item, val) { | |
item.style.opacity = val; | |
item.style.zIndex = val; | |
} | |
setItem(items[0], 1); | |
setInterval(() => { | |
setItem(items[active], 0); | |
active = (active + 1) % items.length; | |
setItem(items[active], 1); | |
}, 3000); | |
})() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment