Saturday, November 29, 2008

[jQuery] Re: [jCarousel]

Something along these lines, perhaps:

$(document).ready(function()
{
    $('#gallery').jcarousel({
        scroll: 1,
        visible: 1,
        itemVisibleInCallback: itemVisibleIn
    });
});

function itemVisibleIn(carousel, li, index, state)
{
    $(li).contents('a').addClass('Current');
}

You can also specify an itemVisibleOutCallback to remove the class once it's
no longer visible.


On Sat, Nov 29, 2008 at 5:22 PM, Alex Hempton-Smith <hempsworth@googlemail.com> wrote:
Thanks Brian,

I've read through that documentation and I'm not sure how I would go about using that to add the 'current' class to the <a> tag?
Would you be able to post some code? I'm still a jQuery n00b!

-- Alex


On Sat, Nov 29, 2008 at 5:40 PM, brian <bally.zijn@gmail.com> wrote:
Create an itemVisibleInCallback function. The second param is the list-item object, from which you can get the anchor.

http://sorgalla.com/projects/jcarousel/#Configuration


On Sat, Nov 29, 2008 at 10:38 AM, Alex <hempsworth@googlemail.com> wrote:

Using the example of external controls (http://sorgalla.com/projects/
jcarousel/examples/static_controls.html
).

When a certain item is visible, how do I add a class such as 'current'
to the <a href="#"> for that item?

Many thanks,
Alex



No comments: