Created
March 2, 2014 01:06
-
-
Save toobulkeh/9300315 to your computer and use it in GitHub Desktop.
EnvyLabs Hero Slider
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
<div class="hero"> | |
<img alt="Illustration Base" height="500" src="images/hero/base.png" width="1040"> | |
<img alt="We Pursue Excellence" class="hero-slide active" height="500" src="images/hero/excellence.png" width="1040"> | |
<img alt="We Practice Transparency" class="hero-slide" height="500" src="images/hero/transparency.png" width="1040"> | |
<img alt="We Foster Education" class="hero-slide" height="500" src="images/hero/education.png" width="1040"> | |
<img alt="We Create Fun" class="hero-slide prev" height="500" src="images/hero/fun.png" width="1040"> | |
<a class="hero-prev" href="#">Prev</a> | |
<a class="hero-next" href="#">Next</a> | |
</div> | |
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
n = function () { | |
function e(e, t, n, r) { | |
this.selector = e; | |
this.setupHero(this.selector, t, n, r) | |
} | |
e.prototype.setupHero = function (e, t, n, r) { | |
var i = this; | |
this.selector = e; | |
this.heroes = $(this.selector); | |
this.hero = this.heroes.first(); | |
this.info = $(t); | |
this.setHero(this.hero); | |
$(n).on("click", function (e) { | |
e.preventDefault(); | |
return i.setHero(i.nextHero(i.hero)) | |
}); | |
$(r).on("click", function (e) { | |
e.preventDefault(); | |
return i.setHero(i.prevHero(i.hero)) | |
}); | |
return this.hero | |
}; | |
e.prototype.setHero = function (e) { | |
this.heroes.removeClass("active prev"); | |
this.hero = e.addClass("active"); | |
this.prevHero(this.hero).addClass("prev"); | |
return this.info.html(this.hero.attr("alt")) | |
}; | |
e.prototype.nextHero = function (e) { | |
var t; | |
return t = e.next(this.selector).length > 0 ? e.next(this.selector) : this.heroes.first() | |
}; | |
e.prototype.prevHero = function (e) { | |
var t; | |
return t = e.prev(this.selector).length > 0 ? e.prev(this.selector) : this.heroes.last() | |
}; | |
return e | |
}(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment