Skip to content

Instantly share code, notes, and snippets.

@toobulkeh
Created March 2, 2014 01:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save toobulkeh/9300315 to your computer and use it in GitHub Desktop.
Save toobulkeh/9300315 to your computer and use it in GitHub Desktop.
EnvyLabs Hero Slider
<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>
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