Download
Demo
- Overview
- Documents
User Rating: 2.8/5 ( 2 votes)
Your Rating:
SilverTrack is a jQuery plugin designed to be extensible through other plugins. It has a small core and comes with very useful plugins.
Source: tulios.github.io
1. INCLUDE CSS AND JS FILES
<link rel="stylesheet" type="text/css" href="stylesheets/base_example.css" media="screen" /> <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script> <script type="text/javascript" src="../lib/jquery-easing-1.3.0.js"></script> <script type="text/javascript" src="../src/jquery.silver_track.js" charset="utf-8"></script> <script type="text/javascript" src="../src/jquery.silver_track_recipes.js" charset="utf-8"></script> <script type="text/javascript" src="../src/plugins/jquery.silver_track.navigator.js" charset="utf-8"></script> <script type="text/javascript" src="../src/plugins/jquery.silver_track.bullet_navigator.js" charset="utf-8"></script> <script type="text/javascript" src="../src/plugins/jquery.silver_track.responsive_hub_connector.js" charset="utf-8"></script>
2. HTML
<div class="track my-track">
<!-- SilverTrack requires only this part -->
<div class="view-port">
<div class="slider-container">
<div class="item"><img src="http://lorempixel.com/230/134/nature/1/"></div>
<div class="item"><img src="http://lorempixel.com/230/134/nature/2/"></div>
<!-- ... -->
</div>
</div>
<!-- My custom navigator links -->
<div class="pagination">
<a href="#" class="prev disabled"></a>
<a href="#" class="next disabled"></a>
</div>
</div>
We will use a very simple markup, SilverTrack receives a container with your items, in our case,'.slider-container' and it leaves up to you to control the view port, so we will use '.view-port' to control de visibility. It also requires 'position: absolute' of your items
3. CSS
.view-port {
width: 960px;
overflow: hidden;
position: relative;
}
.slider-container {
position: relative;
height: 138px;
margin: 0;
padding: 0;
}
.item {
position: absolute;
width: 234px;
height: 138px;
margin-right: 8px
}
4. JAVASCRIPT
var container = $(".my-track");
var track = container.find(".slider-container").silverTrack();
// install the plugins you want, in our case Navigator
track.install(new SilverTrack.Plugins.Navigator({
prev: $("a.prev", container),
next: $("a.next", container)
}));
track.start();
5. OPTIONS
| name | description | default |
|---|---|---|
| perPage | The amount of itens to display | 4 |
| itemClass | The class name that will be used to find the item | item |
| mode | The direction of pagination (horizontal or vertical) | horizontal |
| autoHeight | If it will adjust the track height after each pagination | false |
| cover | When set to true, the plugin will consider the first page as a cover and will consider it as one item | false |
| easing | Animation function used by SilverTrack. This function will be used by $.animate, so you could use any plugin that adds easing functions. Ex: jQuery Easing | swing |
| duration | The duration used by the animation function | 600 |
| animateFunction | If set this function will be used instead of $.animate. The function will receive movement, duration, easing and afterCallback. The movement object will be {left: someNumber} or {height: someNumber}. For an example of how to replace the animation function take a look at css3 animation plugin | null |
6. METHODS
| name | description | parameters |
|---|---|---|
| start | Starts SilverTrack | |
| goToPage | Goes to a specific page when it existsm | page |
| next | Goes to the next page when it exists | |
| prev | Goes to the previous page when it exists | |
| hasNext | Returns true if next page exist | false |
| hasPrev | Returns true if previous page exist | |
| restart | Restarts the position of the items, by default goes to the first page. This method accepts an opts object with page, keepCurrentPage and animate attributes. Default: {page: 1, keepCurrentPage: false, animate: false} | opts |
| install | Installs a plugin. Check out the how to Creating a plugin | plugin |
| reloadItems | Nullifies the items cache forcing the plugin to reload | |
| updateTotalPages | Disables the calculation of totalPages and defines the new one with the informed number | totalPages |
| findPluginByName | Finds an installed plugin by its name. It returns null if the plugin is not installed. Ex: track.findPluginByName("Navigator") | name |
JS Tutorial
