1. INCLUDE CSS AND JS FILES
<!-- Include the CSS -->
<link rel="stylesheet" href="bellows.min.css">
<!-- Optionally include the Theme file -->
<link rel="stylesheet" href="bellows-style.min.css">
<!-- Include dependencies -->
<script src="zepto.min.js"></script>
<script src="velocity.min.js"></script>
<!-- Include bellows.js -->
<script src="bellows.min.js"></script>
2. HTML
<!-- Include the markup -->
<div class="bellows">
<!-- The Accordion Items -->
<div class="bellows__item">
<div class="bellows__header">
<!-- Item Header - Content can be whatever you want -->
</div>
<div class="bellows__content">
<!-- Item Content - Content can be whatever you want -->
</div>
</div>
<div class="bellows__item">
<div class="bellows__header">
<h3>Header</h3>
</div>
<div class="bellows__content">
<p>Content</p>
</div>
</div>
<div class="bellows__item">
<div class="bellows__header">
<h3>Header</h3>
</div>
<div class="bellows__content">
<p>Content</p>
</div>
</div>
</div>
3. JAVASCRIPT
$('.bellows').bellows();
4. OPTIONS
Initialize with options.
$('.bellows').bellows({
singleItemOpen: false,
duration: 200,
easing: 'swing',
open: function(e, ui) {},
opened: function(e, ui) {},
close: function(e, ui) {},
closed: function(e, ui) {}
});
singleItemOpen
default: false
When set to true will force only one item open at a time.
$('.bellows').bellows({
singleItemOpen: true
});
duration
default: 200
Sets the duration for the animation.
$('.bellows').bellows({
duration: 600
});
easing
default: swing
Sets the easing for the animation. Bellows takes all of the same easing properties that Velocity.js accepts.
-
jQuery UI's easings and CSS3's easings ("ease", "ease-in", "ease-out", and "ease-in-out"), which are pre-packaged into Velocity. A bonus "spring" easing (sampled in the CSS Support pane) is also included.
-
CSS3's bezier curves: Pass in a four-item array of bezier points. (Refer to Cubic-Bezier.com for crafing custom bezier curves.)
-
Spring physics: Pass a two-item array in the form of [ tension, friction ]. A higher tension (default: 600) increases total speed and bounciness. A lower friction (default: 20) increases ending vibration speed.
-
Step easing: Pass a one-item array in the form of [ steps ]. The animation will jump toward its end values using the specified number of steps.
For more information, check out Velocity's docs on easing.
$('.bellows').bellows({
easing: 'ease-in-out'
});
open
default: function(e, ui) {}
Triggered every time the selected bellows item is starting to open.
Parameters
Parameter name |
Description |
e |
An Event object passed to the callback |
ui |
An object containing any associated data for use inside the callback |
$('.bellows').bellows({
open: function(e, ui) {
// ui.item contains the item opening
}
});
opened
default: function(e, ui) {}
Triggered every time the selected bellows item has finished opening.
Parameters
Parameter name |
Description |
e |
An Event object passed to the callback |
ui |
An object containing any associated data for use inside the callback |
$('.bellows').bellows({
opened: function(e, ui) {
// ui.item contains the item that opened
}
});
close
default: function(e, ui) {}
Triggered every time an bellows item is starting to close.
Parameter name |
Description |
e |
An Event object passed to the callback |
ui |
An object containing any associated data for use inside the callback |
$('.bellows').bellows({
close: function(e, ui) {
// ui.item contains the item closing
}
});
closed
default: function(e, ui) {}
Triggered every time an bellows item is finished closing.
Parameter name |
Description |
e |
An Event object passed to the callback |
ui |
An object containing any associated data for use inside the callback |
$('.bellows').bellows({
closed: function(e, ui) {
// ui.item contains the item that closed
}
});
5. METHODS
Open
Open the selected bellows item by element reference
$bellows.bellows('open', $('.bellows__item'));
or by index
$bellows.bellows('open', 1);
Close
Close the selected bellows item by element reference
$bellows.bellows('close', $('.bellows__item'));
or by index
$bellows.bellows('close', 1);
Add
Adds new items to bellows, and correctly wraps their content elements. Optional third parameter allows you to replace all existing elements with the ones specified.
$bellows.bellows('add', items);
or replacing existing elements
$bellows.bellows('add', items, true);