--- title: Orbit layout: doc/layouts/default.html --- # Orbit

Orbit is an easy, powerful, responsive image slider that allows users to swipe on touch-enabled devices.

*** {{> examples_orbit_basic}} *** ## How to Setup Orbit Orbit requires minimal HTML markup to function. Our JavaScript takes care of most of the heavy lifting for you. The only thing you need to do is add a `` element to your page. You can then populate it with images, text, and captions. Here's the markup required to implement a basic Orbit slider on your page:

HTML

{{#markdown}} ```html {{> examples_orbit_basic}} ``` {{/markdown}}

Rendered HTML

{{#markdown}} ```html {{> examples_orbit_basic_rendered}} ``` {{/markdown}} *** ## Content Sliders Orbit can also be used with just content and no images.

HTML

{{#markdown}} ```html {{> examples_orbit_content}} ``` {{/markdown}}

Rendered HTML

{{> examples_orbit_content}}
*** ## Deep Linking To link to a particular slide in your Orbit slider you will need to add a `data-orbit-slide` attribute to each slide. Then anywhere on your page you can use `data-orbit-link` to link to that slide.

HTML

{{#markdown}} ```html Goto Slide 1 Goto Slide 2 Goto Slide 3 ``` {{/markdown}}

Rendered HTML

Goto Slide 1 Goto Slide 2 Goto Slide 3 {{> examples_orbit_content}}
*** ## Customize With Sass

We've included a bunch of variables that you'll be able to use if you're into getting SASSy with things.

{{#markdown}} ```scss $include-html-orbit-classes: $include-html-classes; // We use these to control the caption styles $orbit-container-bg: #f5f5f5; $orbit-caption-bg: rgba(0,0,0,0.6); $orbit-caption-font-color: #fff; $orbit-caption-font-size: emCalc(14); $orbit-caption-position: "bottom"; // Supported values: "bottom", "under" $orbit-caption-padding: emCalc(10,14); $orbit-caption-height: auto; // We use these to control the left/right nav styles $orbit-nav-bg: rgba(0,0,0,0.6); $orbit-nav-bg-hover: rgba(0,0,0,0.6); $orbit-nav-arrow-color: #fff; $orbit-nav-arrow-color-hover: #ccc; // We use these to control the timer styles $orbit-timer-bg: rgba(0,0,0,0.6); $orbit-timer-show-progress-bar: true; // We use these to control the bullet nav styles $orbit-bullet-nav-color: #999; $orbit-bullet-nav-color-active: #222; $orbit-bullet-radius: emCalc(18); // We use these to controls the style of slide numbers $orbit-slide-number-bg: rgba(0,0,0,0); $orbit-slide-number-font-color: #fff; $orbit-slide-number-padding: rem-calc(5px); // Graceful Loading Wrapper and preloader $wrapper-class: "slideshow-wrapper"; $preloader-class: "preloader"; ``` {{/markdown}}
*** ## Configuring Orbit It's easy to configure Orbit using our provided JavaScript. You can use with data-attributes or plain old JavaScript. Make sure `jquery.js`, `foundation.js`, and `foundation.orbit.js` have been included on your page before continuing. For example add the following before the closing `` tag: ```html ``` ### Basic Using data-attributes is the preferred method of making changes to our JavaScript. ```html ``` ### Advanced You can also adjust settings using plain old JavaScript. Here's all the available settings: #### JS ```js $(document).foundation({ orbit: { animation: 'slide', // Sets the type of animation used for transitioning between slides, can also be 'fade' timer_speed: 10000, // Sets the amount of time in milliseconds before transitioning a slide pause_on_hover: true, // Pauses on the current slide while hovering resume_on_mouseout: false, // If pause on hover is set to true, this setting resumes playback after mousing out of slide animation_speed: 500, // Sets the amount of time in milliseconds the transition between slides will last stack_on_small: false, navigation_arrows: true, slide_number: true, slide_number_text: 'of', container_class: 'orbit-container', stack_on_small_class: 'orbit-stack-on-small', next_class: 'orbit-next', // Class name given to the next button prev_class: 'orbit-prev', // Class name given to the previous button timer_container_class: 'orbit-timer', // Class name given to the timer timer_paused_class: 'paused', // Class name given to the paused button timer_progress_class: 'orbit-progress', // Class name given to the progress bar slides_container_class: 'orbit-slides-container', // Class name given to the slides container bullets_container_class: 'orbit-bullets', bullets_active_class: 'active', // Class name given to the active bullet slide_number_class: 'orbit-slide-number', // Class name given to the slide number caption_class: 'orbit-caption', // Class name given to the caption active_slide_class: 'active', // Class name given to the active slide orbit_transition_class: 'orbit-transitioning', bullets: true, // Does the slider have bullets visible? circular: true, // Does the slider should go to the first slide after showing the last? timer: true, // Does the slider have a timer visible? variable_height: false, // Does the slider have variable height content? swipe: true, before_slide_change: noop, // Execute a function before the slide changes after_slide_change: noop // Execute a function after the slide changes } }); ``` *** ## Real World Example

Here's an example of a customized Orbit container.

JavaScript

{{#markdown}} ```js $(document).foundation({ orbit: { animation: 'slide', timer_speed: 1000, pause_on_hover: true, animation_speed: 500, navigation_arrows: true, bullets: false } }); ``` {{/markdown}}

HTML

{{#markdown}} ```html
``` {{/markdown}}
*** ## Events There are several events that you can bind to in Orbit. Here's an example of how you can bind to these events: #### HTML ```html ``` #### JS ```js $("#featured1").on("ready.fndtn.orbit", function(event) { console.info("ready"); }); $("#featured1").on("before-slide-change.fndtn.orbit", function(event) { console.info("before slide change"); }); $("#featured1").on("after-slide-change.fndtn.orbit", function(event, orbit) { console.info("after slide change"); console.info("slide " + orbit.slide_number + " of " + orbit.total_slides); }); $("#featured1").on("timer-started.fndtn.orbit", function(event, orbit) { console.info("timer started"); }); $("#featured1").on("timer-stopped.fndtn.orbit", function(event, orbit) { console.info("timer stopped"); }); ``` *** ### Sass Errors? If the default "foundation" import was commented out, then make sure you import this file:

SCSS

{{#markdown}} ```scss @import "foundation/components/orbit"; ``` {{/markdown}}