Skip to content

Instantly share code, notes, and snippets.

@dgoldie
Created January 5, 2011 20:49
Show Gist options
  • Save dgoldie/766979 to your computer and use it in GitHub Desktop.
Save dgoldie/766979 to your computer and use it in GitHub Desktop.
jcarousel insert example
function mycarousel_initCallback(carousel) {
console.log('init');
jQuery('.jcarousel-control a').bind('click', function() {
var size = carousel.size(),
first = carousel.first,
last = carousel.last;
console.log('carousel first = ' + first + ', size = ' + size + ', last = ' + last);
// var addIndex = first - 0.1;
// carousel.add(addIndex, '<li><div></div></li>');
// console.log('carousel add at = ' + addIndex);
$('<li><div></div></li>').insertBefore(carousel.get(first)).hide().show(1000);
var li = carousel.list.children('li');
if (li.size() > 0) {
var wh = 0, i = carousel.options.offset;
li.each(function() {
carousel.format(this, i++);
});
}
// trick it before scrolling
// carousel.first = first + 1;
// carousel.last = last + 1;
// carousel.scroll(first, true);
carousel.size(size + 1);
console.log('carousel after first = ' + first + ', size = ' + carousel.size() + ', last = ' + last);
//carousel.scroll(jQuery.jcarousel.intval(jQuery(this).text()));
return false;
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment