Skip to content

Instantly share code, notes, and snippets.

@JGallardo
Created April 8, 2013 18:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JGallardo/5338991 to your computer and use it in GitHub Desktop.
Save JGallardo/5338991 to your computer and use it in GitHub Desktop.
Orbit-1.2.3 Slider setup
// ==============
// ! SETUP
// ==============
//Global Variables
var activeSlide = 0,
numberSlides = 0,
orbitWidth,
orbitHeight,
locked;
//Initialize
var orbit = $(this).addClass('orbit'),
orbitWrapper = orbit.wrap('<div class="orbit-wrapper" />').parent();
orbit.add(orbitWidth).width('1px').height('1px');
//Collect all slides and set slider size of largest image
var slides = orbit.children('img, a, div');
slides.each(function() {
var _slide = $(this),
_slideWidth = _slide.width(),
_slideHeight = _slide.height();
if(_slideWidth > orbit.width()) {
orbit.add(orbitWrapper).width(_slideWidth);
orbitWidth = orbit.width();
}
if(_slideHeight > orbit.height()) {
orbit.add(orbitWrapper).height(_slideHeight);
orbitHeight = orbit.height();
}
numberSlides++;
});
//Animation locking functions
function unlock() {
locked = false;
}
function lock() {
locked = true;
}
//If there is only a single slide remove nav, timer and bullets
if(slides.length == 1) {
options.directionalNav = false;
options.timer = false;
options.bullets = false;
}
//Set initial front photo z-index and fades it in
slides.eq(activeSlide)
.css({"z-index" : 3})
.fadeIn(function() {
//brings in all other slides IF css declares a display: none
slides.css({"display":"block"})
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment