PDA

View Full Version : Lightbox continous loop help



lykos777
06-16-2011, 06:33 AM
Hi,

Just wondering if I can get some help with making a minor change to lightbox.

I want the images shown to be navigated in a loop instead of stopping at the last image, and to be able to go backwards from the beginning as well.

Im using a modified version of lightbox (attached) that is designed to work with a flash carousel.

I've seen this done in other scripts, but unfortunately I need to use this particular flavor of lightbox to get it working.

Any help would be appreciated, fyi, i found this old post

http://www.dynamicdrive.com/forums/archive/index.php/t-25681.html

and tried it, but didnt get any result.

Thanks

jscheuer1
06-16-2011, 06:54 AM
Starting at line #585 in the attached file you supply we find this function:


//
// updateNav()
// Display appropriate previous and next hover navigation.
//
updateNav: function() {

Element.show('hoverNav');

// If not first image in set, display prev image button
if(activeElement != 0){
Element.show('prevLink');
document.getElementById('prevLink').onclick = function() {
myLightbox.changeElement(activeElement - 1); return false;
}
}

// If not last image in set, display next image button
if(activeElement != (elementArray.length - 1)){
Element.show('nextLink');
document.getElementById('nextLink').onclick = function() {
myLightbox.changeElement(activeElement + 1); return false;
}
}

this.enableKeyboardNav();
},

Replace it with this one:


//
// updateNav()
// Display appropriate previous and next hover navigation.
//
updateNav: function() {

Element.show('hoverNav');

// Display prev image button
Element.show('prevLink');
document.getElementById('prevLink').onclick = function() {
var prev = activeElement != 0? activeElement - 1 : elementArray.length - 1;
myLightbox.changeElement(prev); return false;
}

// Display next image button
Element.show('nextLink');
document.getElementById('nextLink').onclick = function() {
var next = activeElement != (elementArray.length - 1)? activeElement + 1 : 0;
myLightbox.changeElement(next); return false;
}

this.enableKeyboardNav();
},

lykos777
06-17-2011, 12:29 AM
Thankyou very much John, worked like a charm!