Created
April 1, 2015 19:02
-
-
Save simplesthing/d9d8325bc2f6237865a1 to your computer and use it in GitHub Desktop.
set css for each repeated section JS
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
_.map(document.querySelectorAll('.challenge'), function(element) { | |
var position; | |
position = element.getAttribute('data-position'); | |
// determine direction of slide and apply styles | |
if(position > scope.index){ // slide right | |
element.classList.add('right'); | |
element.setAttribute('style', 'display:block; width:' + avgWidth + 'px; float:left;'); | |
} | |
if(position < scope.index) { // slide left | |
element.classList.add('left'); | |
element.setAttribute('style', 'display:block; width:' + avgWidth + 'px; float:right;'); | |
} | |
if(position === scope.index) { // expand center | |
element.setAttribute('style', 'display:block; width:' + avgWidth + 'px; float:left; background-image:linear-gradient(rgba(0, 0, 0, 0.0),rgba(0, 0, 0, .25)), url(images/challenges/hero-background.png), url(images/challenges/'+scope.challenge.attributes.image+'); background-repeat:no-repeat; background-size: cover; background-origin:border-box'); | |
element.querySelector('.content').style.display = 'none'; // hide inner content | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment