UNPKG

zurb-foundation-5

Version:

Foundation 5 for npm (no code modification from original repo)

121 lines (68 loc) 4 kB
--- title: Clearing --- <h3 class="subheader">Since we didn't intend Orbit to handle variable-height content, we decided to create a plugin that would. Clearing makes it easy to create responsive lightboxes with any size image.</h3> *** {{> examples_clearing_basic}} *** ## Build Your Clearing Lightbox There is only one way to build a Clearing lightbox, using our predefined class and data-attribute structure. We've made it really easy: gather some images, decide on their order, and put them into an ul with a `.clearing-thumbs` class. In order to get Clearing to build itself properly, you'll need to have JavaScript properly included. We outline [Clearing JS](#js) a bit further down the page. Once you get your JS hooked up, you'll need to add `data-clearing` to your list container. Here's an example of the most basic markup needed: <h4>HTML</h4> {{> examples_clearing_basic_rendered}} ### Styling the List We're using the `.th` class from Foundation to style the thumbnails in the Clearing example at the top of the page. You can also use `@include thumb;` in SCSS to use those same styles. *** ## Start From a Featured Image Sometimes you don't want to show a gallery full of images on your site, but you want to open the gallery from a single image. By including all of your images in a `.clearing-feature` list and using `.clearing-featured-img` on the `<li>` of your choice, you'll be able to hide the rest of the images in the on-page gallery. If you want to show more than one, try using our `.hide` class to set the ones you don't want to `display: none;`. <h4>HTML</h4> {{> examples_clearing_featured}} *** ## Including Captions Another common use-case for Lightboxes is to include a caption per image. We've made this quick and easy by using data-attributes to hold the content. You'll just attach this attribute to the image it belongs to and voila! Here's the code example: **Note:** You can now use HTML inside the data-caption attribute. <h4>HTML</h4> {{> examples_clearing_captions}} *** ## Accessibility <p class="panel">This component is not yet accessible. Stay tuned for updates in future releases.</p> *** ## Available SCSS Variables We opted not to create mixins for this plugin because it relies on classes in the JS to work. These variables should give you the control you need to change styles as you see fit: <h4>SCSS</h4> {{> examples_clearing_variables}} *** ## Using the Javascript <div class="panel"> Before you can use Clearing you'll want to verify that jQuery and `foundation.js` are available on your page. You can refer to the [Javascript documentation]({{relative absolute 'dist/docs/javascript.html'}}) on setting that up. </div> Just add `foundation.clearing.js` AFTER the `foundation.js` file. Your markup should look something like this: <h4>HTML</h4> {{> examples_clearing_javascript}} Required Foundation Library: `foundation.clearing.js` ### Optional Javascript Configuration Clearing supports `data-options` on-the-fly configuration: <h4>JS</h4> {{> examples_clearing_data_options}} ### Available Javascript Events Clearing supports several javascript events that you can listen to: <ul> <li><code>open.fndtn.clearing</code> before a thumbnail is expanded</li> <li><code>opened.fndtn.clearing</code> after the large image has opened</li> <li><code>close.fndtn.clearing</code> before the large image is closed</li> <li><code>closed.fndtn.clearing</code> after the large image has closed</li> <li><code>change.fndtn.clearing</code> when the large image changes</li> <li><code>resized.fndtn.clearing</code> after the large image is resized, before it becomes visible</li> </ul> <p>Here is an example of binding to the open event.</p> <h4>JS</h4> {{> examples_clearing_events}} *** ### Sass Errors? If the default "foundation" import was commented out, then make sure you import this file: <h4>SCSS</h4> {{#markdown}} ```scss @import "foundation/components/clearing"; ``` {{/markdown}}