views:

1258

answers:

1

I am looking for a JQuery solution to something like the rotating banner located at http://www.bazaarvoice.com.

One where it has a timed scroll but also allows the user to toggle by rolling over tabs. Anyone know of a good, easy to style one?

+1  A: 

Use the Cycle Lite plugin for jQuery. It's got a vert small footprint and all the features you need:

See more advanced demos right here.

Edit: here's a sample code for you:
You'll need the Cycle plugin, not the Cycle Lite plugin.
HTML:

<div id="slideshow">
    <ul class="pager">
        <!-- will be populated with thumbs by JS -->
    </ul>
    <!-- each div is considered as a slide show -->
    <div><img src="/images/banner1.png" />You can place text here too !</div>
    <div><img src="/images/banner2.png" /></div>
    <div><img src="/images/banner3.png" /></div>
</div>

CSS:

.thumb.selected {
    border: 2px gray solid;
}

ul.pager li {
    list-style: none;
    float: left;
    width: 200px;
    height: 80px;
    background-color: #eee;
}

#slideshow > div {
    background-color: #eee;
    border: 1px solid #ddd;
}

Javascript:

$("#slideshow").cycle({ 
    fx:           'fade',  // name of transition effect (or comma separated names, ex: fade,scrollUp,shuffle) 
    timeout:       1000,   // milliseconds between slide transitions (0 to disable auto advance) 
    speed:         400,    // speed of the transition (any valid fx speed value) 
    pager:         "#tabs",// selector for element to use as pager container 
    pagerClick:    null,  // callback fn for pager clicks:  function(zeroBasedSlideIndex, slideElement) 
    pagerEvent:   'hover',// name of event which drives the pager navigation 
    pagerAnchorBuilder: function(i, slide){// callback fn for building anchor links:  function(index, DOMelement) 
        return '<li class="thumb" id="thumb-1"><img src="' + slide.src + '" height="30" width="40" /></a></li>';
    },
    before: function(){ // deselect all slides
        $(".thumb").removeClass('selected');
    },
    after: function(foo, bar, opts){ // select current slide
        $("#thumb-"+opts.currSlide).addClass('selected');
    }, 
    fit:           1,     // force slides to fit container 
    pause:         1,     // true to enable "pause on hover" 
    pauseOnPagerHover: 1, // stop slideshow when pagers are being hovered
    autostop:      0,     // true to end slideshow after X transitions (where X == slide count) 
    autostopCount: 0,     // number of transitions (optionally used with autostop to define X)  
    slideExpr:     "div", // all content of div#slider is a slide. but not the pager
    fastOnEvent:   100,   // force fast transitions when triggered manually (via pager or prev/next); value == time in ms 
});

Enjoy, it's untested, but should work.

Edit2:
Replace the pagerAnchorBuilder option with return '<li class="thumb" id="thumb-1"><img src="' + slide.src + '" /></a></li>';

I guess you want to change the width and/or the height. Juste remove the HTML height, and use a CSS property : .thumb img { height: 10px; width: 10px; } You can also add some custom CSS properties.

Daan
I think I need a dumbed down version of this. I am not good enough to know how to do it without a tutorial yet.
bgadoci
Ok, I added some sample code to help you. You'll have to finish it, and to add some sexy CSS.Tell me if it doesn't work.
Daan
Wow, you are freaking awesome man. Thanks so much. I am going to implement this later today and will let you know. Thanks for taking the time.
bgadoci
There is all kinds of files in the download. Is there any problem with just using the jquery.cycle.all.min.js?
bgadoci
Nevermind. I got it working. Thanks.
bgadoci
I'm having trouble building the anchors. I think I do this in the .js file but not exactly sure how and where.
bgadoci
What do you call "the anchors" ?
Daan
The little text or image links that the person hovers over and causes it to pause.
bgadoci
They are being constructed with the pagerAnchorBuilder option: See my 2nd edit to give this custom CSS.
Daan