Killer Carousel Example: Navigation buttons

Applies from version 1.1 rev 1311271343

These examples shows how you can implement navigation buttons with a carousel, in addition to the usual mouse, wheel or touch actions.

By setting the showNavigation:true property, a default set of navigation buttons will appear in the bottom right.

The buttons are styled via the killercarousel.css file, and styled using the following CSS classes:

In addition, the classes .active and .last will be applied to the appropriate buttons so you can style those states differently.

Positioning

The set of buttons is positioned using the navigationHorizontalPos and navigationVerticalPos properties.

Here are some examples

Default Navigation Buttons

Default buttons appear near bottom-right, equivalent to:

navigationVerticalPos:'bottom:15px', navigationHorizontalPos:'right:15px'

Salvator Mundi 1519
St. John the Baptist 1516
Lady with an Ermine 1490
St. Jerome in the Wilderness 1480
Head of a Woman 1508
St. John the Baptist 1516
The Virgin and Child with St Anne and St John the Baptist 1500
Madonna of the Yarnwinder 1507
The Virgin and Child with St. Anne 1508
Madonna of the Carnation 1480

Vertical Navigation Buttons

This was created by simply overriding the CSS like this:


/* Make buttons square and yellow. */
.kc-nav-button {
    clear:both;
    margin-bottom: 5px;
    width:10px;
    height:10px;
    background-color: #fc0;
    border-radius:0px;
}

/* No margin on last one. */
.kc-nav-button.last {
    margin-bottom:0;
}

/* White active button. */
.kc-nav-button.active {
    background-color: #fff;
}    
Salvator Mundi 1519
St. John the Baptist 1516
Lady with an Ermine 1490
St. Jerome in the Wilderness 1480
Head of a Woman 1508
St. John the Baptist 1516
The Virgin and Child with St Anne and St John the Baptist 1500
Madonna of the Yarnwinder 1507
The Virgin and Child with St. Anne 1508
Madonna of the Carnation 1480

Navigation Parent

The default parent of the navigation buttons is the wrapping element used for the carousel (in these examples, the big rectangle with the grey background).

You can specify a different parent by using the navigationParent property. This allows you to specify a selector to any element in the page to use as the parent.

In this example, we've attached the navigation to an element that sits below the carousel wrapping element.

Salvator Mundi 1519
St. John the Baptist 1516
Lady with an Ermine 1490
St. Jerome in the Wilderness 1480
Head of a Woman 1508
St. John the Baptist 1516
The Virgin and Child with St Anne and St John the Baptist 1500
Madonna of the Yarnwinder 1507
The Virgin and Child with St. Anne 1508
Madonna of the Carnation 1480

Forwards and Backwards Buttons

Forwards and backwards buttons can be easily implement using the API.

In this example, we have wired up two buttons to work with the carousel using the following code:

$(function(){
    // Get instance of Killer Carousel.
    var kc = $('#kc-4').data('KillerCarousel');                    
    // Bind events to buttons.
    $('#forwards-button').click(function(){
        // Call api function to move forwards.
        kc.animateToRelativeItem(1);
    });
    $('#backwards-button').click(function(){
        // Call api function to move backwards.
        kc.animateToRelativeItem(-1);
    });
});

Try them:

Salvator Mundi 1519
St. John the Baptist 1516
Lady with an Ermine 1490
St. Jerome in the Wilderness 1480
Head of a Woman 1508
St. John the Baptist 1516
The Virgin and Child with St Anne and St John the Baptist 1500
Madonna of the Yarnwinder 1507
The Virgin and Child with St. Anne 1508
Madonna of the Carnation 1480

info

©2015 Star Plugins