views:

118

answers:

2

Hi, I am implementing a scrollable for a portfolio gallery.

(scrollable = scrollable plugin from http://flowplayer.org/tools/index.html )

There will be one item visible at a time.

By default, scrollable positions the prev/next buttons outside of the image area and clicking on the current image advances the scrollable content.

  1. I would like to have the prev/next render within the image area.
  2. I would like to have an image caption appear when mousing over the lower part of the image.

Mock-up: http://i303.photobucket.com/albums/nn160/upstagephoto/mockups/scrollable_mockup.jpg

Any ideas on how to achieve one or both of these?

Thank you!

A: 

The main part of your approach will be like this in your html:

<div id="mainContainer">
  <div class="scrollable">
    <div class="items">
      <div class="scrollableEl">
         <img src="yourimage.jpg" />
         <div class="caption">Your caption</div>
      </div>

      <div class="scrollableEl">
         <img src="yourimage2.jpg" />
         <div class="caption">Your caption 2</div>
      </div>

      ... so on ...
    </div>
  </div>
  <a href="#" class="prev">&laquo;</a>
  <a href="#" class="prev">&laquo;</a>
</div>

And like so in your CSS:

.scrollable {
    position:relative;
    overflow:hidden;
    width: 660px;
    height:90px;
}

.scrollable .items {
    width:20000em;
    position:absolute;
}

.items .scrollableEl {
    float:left;
    positon: relative;
}

.items .scrollableEl .caption {
    display:none;
    position: absolute;
    bottom: 0;
    height: 100px;
    width: 660px;
}

.items .scrollableEl:hover .caption { /*this will show your caption on mouse over */
    display:none;
}

.next, .prev {
    position: absolute;
    top: 0;
    display: block;
    width: 30px;
    height: 100%;
}
.next {
    right: 0;
}
.prev {
    left: 0;
}
#mainContainer {
    position: relative;
}

The javascript should be fairly standard. Hope this helps!

Jakub Hampl
Thank you, this is exactly what I need. I am accepting it with a couple comments: .items .scrollableEl:hover .caption should have display:block instead of display:none.In the HTML, the second <a href="#" class="prev">«</a> should be replaced with<a href="#" class="next">»</a>
aaandre
A: 

DEMO: http://jsbin.com/ijede/2 SOURCE: http://jsbin.com/ijede/2/edit

$(function() {
    // 5 minute slide show ;-)
    $('.next,.prev').click(function(e) {
        e.preventDefault();
        var pos = parseInt($('.current').attr('id').split('_')[1]);
        var tot = $('.slides a').size() - 1;
        var click = this.className;
        var new_pos = (click == 'next') ? pos + 1: pos - 1;
        var slide = ( click == 'next') ? 
                    (pos < tot ? true : false) : (pos > 0 ? true : false);

        if (slide) $('.current').toggle(500,function() {
          $(this).removeClass('current');
        });
        $('#pos_' + new_pos).toggle(500,function() {
            $(this).attr('class', 'current');
        });
    });
    //cross-browser div :hover
    $('.next,.prev').hover(function() {
      $(this).children().children().fadeIn(500);
    },function() {
      $(this).children().children().fadeOut(500);
    });
    //auto add unique id to each image
    $('.slides a').each(function(e) {
        $(this).attr('id', 'pos_' + e);
        if (!e) $(this).attr('class', 'current');
    });
});​

CSS on source!

NOTE: since read the plugin doc require more time for me than make a slideshow from scratch, i have maked a fresh one!

hope you like it!

aSeptik
Thank you for your answer. I needed a very specific solution which I found in the first reply.
aaandre