Orbit

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


  • slide 1
    Caption One.
  • slide 2
    Caption Two.
  • slide 3
    Caption Three.

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 <ul data-orbit></ul> 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

<ul class="example-orbit" data-orbit> <li> <img src="../assets/img/examples/satelite-orbit.jpg" alt="slide 1" /> <div class="orbit-caption"> Caption One. </div> </li> <li> <img src="../assets/img/examples/andromeda-orbit.jpg" alt="slide 2" /> <div class="orbit-caption"> Caption Two. </div> </li> <li> <img src="../assets/img/examples/launch-orbit.jpg" alt="slide 3" /> <div class="orbit-caption"> Caption Three. </div> </li> </ul>

Rendered HTML

<div class="orbit-container"> <ul data-orbit class="example-orbit orbit-slides-container"> <li> <img src="http://placehold.it/1000x300/A92B48/fff" alt="slide 1" /> <div class="orbit-caption"> Caption One. </div> </li> <li class="active"> <img src="http://placehold.it/1000x300/EE964D/fff" alt="slide 2" /> <div class="orbit-caption"> Caption Two. </div> </li> <li> <img src="http://placehold.it/1000x300/FDC43D/fff" alt="slide 3" /> <div class="orbit-caption"> Caption Three. </div> </li> </ul> <!-- Navigation Arrows --> <a href="#" class="orbit-prev">Prev <span></span></a> <a href="#" class="orbit-next">Next <span></span></a> <!-- Slide Numbers --> <div class="orbit-slide-number"> <span>1</span> of <span>3</span> </div> <!-- Timer and Play/Pause Button --> <div class="orbit-timer"> <span></span> <div class="orbit-progress"></div> </div> </div> <!-- Bullets --> <ol class="orbit-bullets"> <li data-orbit-slide-number="1"></li> <li data-orbit-slide-number="2" class="active"></li> <li data-orbit-slide-number="3"></li> </ol>

Content Sliders

Orbit can also be used with just content and no images.

HTML

<ul class="example-orbit-content" data-orbit> <li data-orbit-slide="headline-1"> <div> <h2>Headline 1</h2> <h3>Subheadline</h3> </div> </li> <li data-orbit-slide="headline-2"> <div> <h2>Headline 2</h2> <h3>Subheadline</h3> </div> </li> <li data-orbit-slide="headline-3"> <div> <h2>Headline 3</h2> <h3>Subheadline</h3> </div> </li> </ul>

Rendered HTML

  • Headline 1

    Subheadline

  • Headline 2

    Subheadline

  • Headline 3

    Subheadline


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

<a data-orbit-link="headline-1" class="small button"> Goto Slide 1 </a> <a data-orbit-link="headline-2" class="small button"> Goto Slide 2 </a> <a data-orbit-link="headline-3" class="small button"> Goto Slide 3 </a>

Rendered HTML

Goto Slide 1 Goto Slide 2 Goto Slide 3
  • Headline 1

    Subheadline

  • Headline 2

    Subheadline

  • Headline 3

    Subheadline


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.

$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";

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 <body> tag:

<script src="js/jquery.js"></script> <script src="js/foundation.js"></script> <script src="js/foundation.orbit.js"></script>

Basic

Using data-attributes is the preferred method of making changes to our JavaScript.

<ul data-orbit data-options="animation_speed:1500;"> ... </ul>

Advanced

You can also adjust settings using plain old JavaScript. Here's all the available settings:

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

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

HTML

<ul data-orbit data-options="animation:slide; animation_speed:1000; pause_on_hover:true; animation_speed:500; navigation_arrows:true; bullets:false;"> </ul>
  • slide 1
  • slide 2
  • slide 3

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

<ul id="featured1" data-orbit> ... </ul>

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

@import "foundation/components/orbit";
Stay on top of what’s happening in responsive design.

Sign up to receive monthly Responsive Reading highlights. Read Last Month's Edition ยป